Eclipse + Selenium + TestNG configure, start (IE, Chrome, Edge, Firefox) and error troubleshooting

First, the conventional configuration TestNG eclipse

There are two ways to install TestNG plugin, one is one is off-line.

1, offline

( 1 ) downloads the installation package testng into http://beust.com/eclipse download.

( 2 ) After downloading zipped file, click on "help" in eclipse menu bar, select the drop-down menu in the "Install New Software". The following interface
Here Insert Picture Description( 3 ) Click the Add button
Here Insert Picture Description

( 4 ) project on the right can be seen in the following figure, the installation is successful
Here Insert Picture Description

2, line installation

( 1 ) direct the picture, after entering Marktplace search TestNG, can be installed directly
Here Insert Picture Description

3, the installation will ask

Whether online or offline installation process will appear stuck phenomenon Here Insert Picture Description
Note: Installation stuck solutions https://blog.csdn.net/qq_27009225/article/details/103743824

Second, the configuration Selenium WebDriver

1. Download

https://selenium.dev/downloads/
download the corresponding version of java
Here Insert Picture Description

2, unzip the downloaded file

The file appears as follows
Here Insert Picture Description
Note: You must have three files to import the project, import only issue an error message will appear outside the two jar package: java.lang.NoClassDefFoundError: com / google / common / collect / ImmutableMap

3, import file

Here Insert Picture Description

Third, the browser downloads the corresponding drive

Three drive driver installed browser

  • Chrome driver chromedriver Download: chromedriver
  • Firefox Download Driver geckodriver: geckodriver
  • Download Driver IEdriver IE: IEdriver
  • Edge driver edgedriver Download: edgedriver
  • Selenium IEDriverServer version number and version number must be consistent

View selenium Python versionHere Insert Picture Description

1, Chrome drive

Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:25606/status] to be available after 20012 ms
	at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
	at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:190)
	... 10 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
	at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:140)
	at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
	... 11 mor

2, configure the environment variables ChromeDriver

  • Copy webdriver to file under Application Chrome browser installation directory

Of course, the configuration environment variable is not mandatory, but it will save a little thing

Here Insert Picture Description

Fourth, call the instance

  • If you configure webdriver environment variables do not have this line of codeSystem.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver",
//				"C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chromedriver.exe");
		WebDriver wd = new ChromeDriver();
		wd.get("https://www.baidu.com");
		Thread.sleep(1000);
		wd.findElement(By.id("kw")).sendKeys("I Love You!");
		Thread.sleep(1000);
		wd.findElement(By.id("su")).click();
		Thread.sleep(1000);
		wd.quit();

Four, IE promoter given

1、Unexpected error launching Internet Explorer

selenium.common.exceptions.SessionNotCreatedException: Message: Unexpected error launching Internet Explorer. Browser zoom level was set to 250%. It should be set to 100%


2, solve

Here Insert Picture Description

3, the second method

My blog

Fifth, start Edge error

Error message: urllib3.exceptions.ProtocolError

urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, '远程主机强迫关闭了一个现有的连接。', None, 10054, None))

1, View edge version

At the bottom

Method 1: Edge18 previous version

  Download the corresponding version of MicrosoftWebDriver

Here Insert Picture Description

Second way: After the release of Edge18

  Enter the command line
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0

Remember : this time to ensure the Python installation directory of the previous version did not MicrosoftWebDriver, otherwise Python will first find the default Python installation MicrosoftWebDriver directory, has been an error

Here Insert Picture Description

Sixth, start Firefox error

1、Service geckodriver unexpectedly exited

Message: Service geckodriver unexpectedly exited. Status code was: 2

2, corresponding to the downloaded driver

Here Insert Picture Description
Here Insert Picture Description

Published 59 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_27009225/article/details/103743264