вівторок, 10 червня 2014 р.

How to set path to webdriver ie driver in pom.xml

How to set path to webdriver ie driver in pom.xml?
Selenium give us a possibility to run the same test in different browsers (FireFox, Internet Explorer, Safari, Opera, Chrome), only one thing you should do before that. You should say to Selenium where you driver browser is located, download needed driver. And as usual we have a several ways to make it, I give you an example for IE Driver Server.

1. First and easy way is: just add your driver location to %PATH% environment variable.
2. Second: create environment variable webdriver.ie.driver and set path where you placed driver. After that you can instanciate webdriver in the code
3. Third: or you can set path to driver instantly in the code
 ...  
 File file = new File("C:/Selenium/iexploredriver.exe");  
 System.setProperty("webdriver.ie.driver", file.getAbsolutePath());  
 WebDriver driver = new InternetExplorerDriver();   
 ...  
4. Forth: or you can set driver via line argument when launch tests in command line
 C:\> java -jar -Dwebdriver.ie.driver=""C:/Selenium/iexploredriver.exe"   
5. Fifth: but if we are talking about automation I prefer CI TeamCity, SVN and maven tool. The lovely maven-surefire-plugin give us a possibility to launch tests using maven goal test. Set path to driver as system properties for this plugin.
 ...  
 <webdriver.ie.driver>${basedir}\external_resources\${iedriverserver.version}\IEDriverServer.exe</webdriver.ie.driver>  
 ...  
 <plugin>  
   <groupId>org.apache.maven.plugins</groupId>  
   <artifactId>maven-surefire-plugin</artifactId>  
   <inherited>true</inherited>  
     <configuration>  
       <systemPropertyVariables>  
         <webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>  
       </systemPropertyVariables>  
       <testFailureIgnore>true</testFailureIgnore>  
       <includes>  
         <include>**/*Stories.java</include>  
       </includes>  
     </configuration>  
 </plugin>  
 ...  

Useful links:

https://code.google.com/p/selenium/wiki/InternetExplorerDriver

Немає коментарів:

Дописати коментар