5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

selenium2での記述サンプル --ignore-certificate-errorへの対応

Posted at

基本的な使い方。
Optionで"test-type"を渡してやらないと--ignore-certificate-errorがどうしたこうしたというエラーがでる。

ソース

test.java
package com.html.sample;
import java.util.Arrays;

import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class Sample01 {

 @BeforeClass
 public static void Setup() {
  System.setProperty("webdriver.chrome.driver", "./driver/chromedriver");
 }

 @Test
 public void test() {
	 
	 //WebDriverのオプションを定義
	 ChromeOptions options = new ChromeOptions();
	 //--ignore-certificate-errorの出力を防止する
	 options.addArguments("test-type");
	 
	 WebDriver driver = new ChromeDriver(options);
	
	 //googleにアクセス
	 driver.get("http://www.google.co.jp");
	 
	 //検索要素を指定
	 WebElement element = driver.findElement(By.id("gbqfq"));
	
	 //検索Keyを設定
	 element.sendKeys("apple 新製品");
	
	 //検索
	 element.submit();
	
	 //終了
	 driver.quit();
 }
}
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?