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();   
 ...  
 C:\> java -jar -Dwebdriver.ie.driver=""C:/Selenium/iexploredriver.exe"   
 ...  
 <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
 
 
Немає коментарів:
Дописати коментар