Local use of drivers

When running a suite locally through an IDE environment, the framework should store and point to the required driver files for each browser. The standalone server is not required when running locally (if running Appium to test mobile devices, you must however run the Appium server locally). The reason you want to store the files in the repo for the framework is to provide a means for all users to not have to download the driver files and install them in their local environment.

Also, when the driver is started locally, it needs a path to find the driver file, and that should be stored in a properties file, as it is passed into the driver class when it is instantiated. Here is how that is done for each browser, using the Windows platform as an example:

// store these in a properties file

selenium.rev
=3.7.0
gecko.rev=0.19.0
chrome.rev=2.33
edge.rev=
15.15063
ie.rev=x64_3.7.0
opera.rev=2.30
// extract these properties during driver creation

gecko.driver.windows.path
=../myPath/selenium-[selenium.rev]/gecko-[gecko.rev]/geckodriver.exe

chrome.driver.windows.path=../myPath/selenium-[selenium.rev]/chrome-[chrome.rev]/chromedriver.exe

microsoftedge.driver.path=../myPath/selenium-[selenium.rev]/edge-[edge.rev]/MicrosoftWebDriver.exe

ie.driver.path=../myPath/selenium-[selenium.rev]/ie-[ie.rev]/IEDriverServer.exe

opera.driver.windows.path=../myPath/selenium-[selenium.rev]/opera-[opera.rev]/operadriver.exe

After defining these in a properties file, you can extract them on the fly when the driver is created in the setDriver method:

// setup local props in setDriver method
...

Properties props = new Properties();
props.load(new FileInputStream("myPropsFile"));

if ( environment.equalsIgnoreCase("local") ) {
System.setProperty("webdriver.gecko.driver",
props.getProperty("gecko.driver.windows.path"));

System.setProperty("webdriver.chrome.driver",
props.getProperty("chrome.driver.windows.path"));

System.setProperty("webdriver.ie.driver",
props.getProperty("ie.driver.path"));

System.setProperty("webdriver.edge.driver",
props.getProperty("microsoftedge.driver.path"));

System.setProperty("webdriver.opera.driver",
props.getProperty("opera.driver.windows.path"));

webDriver.set(new DriverName(caps));
}

...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.161.116