Web page automation with selenium

  • introduce
  • Use version

selenium 3.8

  • Setup steps
  •  1) Target machine

If it is ie11, in internet options -> security, all areas, check "enable protected mode"

Add the directory where IEDriverServer.exe is located to the PATH

If remote testing is provided, start selenium-server-standalone-3.8.1.jar

  •  2) The machine that initiated the test

Code example:

//This is a remote test: WebDriver driver = new RemoteWebDriver(new URL("http://192.168.1.118:4444/wd/hub"),DesiredCapabilities.internetExplorer());
		WebDriver driver = new InternetExplorerDriver();
//local test
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		driver.get("https://fpdk.tax.sh.gov.cn/");// Jump to JD.com homepage
				((JavascriptExecutor) driver).executeScript("$(\"#password\").val('111111111111')");
		((JavascriptExecutor) driver).executeScript("$('#submit').click()");

		System.out.println(driver.getTitle());

 

  • Download jar package and demo java project: https://pan.baidu.com/s/1hucTSGG

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326264899&siteId=291194637