This is the 25th day of my participation in the August Genwen Challenge.More challenges in August

I wrote this blog note when I was just learning it. At that time, I was still in the 1 to 2 version, and the process of setting up the environment was more complicated than now.

I believe that those who have searched for this article have asked what Selenium is. Here, I will not repeat the description and directly cut to the topic: environment building.

Selenium1 introduction

Selenium1 (selenium IDE only supports Firefox installation) Selenium RC needs to run Selenium service, Selenium 2 (advanced WebDriver includes server+ Server source code) support multi-language development, multi-browser execution;

2. Both require a JDK environment, Jnuit4, selenium server-standalone, and jar packages for the environment shown below.

In the picture, Drivers is the browser driver file IEDriver and chromeDriver, both of which have Selenium-server or Selenium-server-standalone.

For apache-Maven, you need to configure the M2_HOME installation path. Add %M2_HOME%\bin before path.

4, verify the MVN environment: run CMD command window echo % variable name %(%M2_HOME%) output directory; MVN -v Outputs JDK, Maven, and system information.

Selenium -server-standalone. Jar (selenium-server-standalone) If not import can be due to can not find the com/Google/common/base/Function and error;

Selenium-server-src: select properties from the selenium server.

7, seleniumwebdriver testing ie browser to an error, the Exception in the thread “main” org. Openqa. Selenium. Remote. SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stackTrace information) Command duration or timeout: 1.26 seconds Build info: version: ‘2.33.0’, Revision: ‘4e90c97’, time: ‘2013-05-22 15:33:32’ System info: os.name: ‘Windows 7’, OS. arch: ‘AMd64’, os.version: ‘6.1’, java.version: ‘1.7.0\_80’ Driver info: org.openqa.selenium.ie.InternetExplorerDriver at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at Sun. Reflect. DelegatingConstructorAccessorImpl. NewInstance (Unknown Source), because of the IE security Settings to add the following code, a new method with defined parameters ()

Method one:

/ / IE browser security Settings / / DesiredCapabilities caps = DesiredCapabilities internetExplorer (); //caps.setCapability(InternetExplorerDriver.INTRODUCE\_FLAKINESS\_BY\_IGNORING\_SECURITY\_DOMAINS,true); //internetexploredriver (caps) defines parameters //WebDriver driver = new InternetExplorerDriver(caps);Copy the code

Method two: Ie browser options – security including IE itself or local and trust, security performance are enabled or disabled protection mode:

Selenium WebDriver is incompatible with Firefox. The webDriver version is Selenium-Java-2.44.0, and the Firefox version is 40.0, so it is not compatible. The compatibility relationship is as follows:

2.25.0 - > 18 19 2.31.0 2.30.0 - > - > 20 2.42.2 2.44.0-29 - > > 33 (31201 4/12/1) does not support 2.45.0 2.53.1 - > - > 36 47; SeleniumWebdriver2.53.1 + Firefox47.0 (installed in C:/Program Files/Mozilla Firefox/Firefox.exe) System.setproperty (webDriver.Firefox. Exe, C:/Program Files/Mozilla Firefox/Firefox. / / System. SetProperty (" webdriver. Ie. Driver ". "D: \ \ \ \ Program Files \ \ \ \ selenium2 (x86) \ \ \ \ Drivers \ \ \ \ IEDriverServer exe"); / / System. SetProperty (" webdriver. Chrome. Driver ", "D: / Program Files (x86)/selenium2 / Drivers/chromedriver. Exe");Copy the code

Selenium3, this blog is meaningless; Here’s a look at selenium’s history: