WebDriver is not set


#1

I am getting the following Exception :-

Under project.properties, I have pasted this code

################################################################################

1) project.properties

## The file with test run specific settings.
com.xceptance.xlt.testPropertiesFile = test.properties

# Include the properties for browser setup for test automation.
com.xceptance.xlt.propertiesInclude.0 = browser.properties
com.xceptance.xlt.propertiesInclude.1 = myproject.properties

2) myproject.properties

## Browser executables and Browser Drivers
# use Front Slash or 2 Back Slash for dir seperation

# Google Chrome
xlt.webDriver.chrome.pathToBrowser = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe
xlt.webDriver.chrome.pathToDriverServer = D:/project/SeleniumTestScripts/chromedriver_win32/chromedriver.exe

# Firefox
xlt.webDriver.firefox.pathToBrowser = D:/programs/FF_47/firefox.exe
xlt.webDriver.firefox.pathToDriverServer = D:/project/SeleniumTestScripts/geckodriver-v0.18.0-win64/geckodriver.exe

But I am getting the following exceptions for these classes

Class A).

public class AddToCart extends AbstractWebDriverScriptTestCase
{

/**
 * Constructor.
 */
public AddToCart()
{
	 super(BrowserDriver.getChromeWebDriver(),"www.google.com");
}

//…//

Class B);

public class BrowserDriver{

public static WebDriver getChromeWebDriver(){
    capabilities = DesiredCapabilities.chrome();
    driver = new ChromeDriver(capabilities);
    return driver;
}

Exception:

java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;

What is the need for mapping in properties file, if we require System properties ?

Any help would be apprieciated


#2

As you construct the driver by yourself, you’ll have to set the appropriate Selenium properties as System properties.
XLT’s properties are only effective when our code is used, more specifically, DefaultWebDriverFactory.


#3

But these properties are taken if there are 2 test case files.
for the first one i wil get the exception, but for the second, it will works.

How or when is the super() called ?
I am using the Script Developer exported test cases in the class AddToCart

public class AddToCart extends AbstractWebDriverScriptTestCase
{

/**
 * Constructor.
 */
public AddToCart()
{
	 super(BrowserDriver.getChromeWebDriver(),"https://dev05-xyz-testserver.net");
}

@Test
public void test() throws Throwable
{
//
// ~~~ OpenStartPage ~~~
//
startAction(“OpenStartPage”);
//…// test scripts

Is there any implicit variables provided by XLT to get the key / values we defined in the property files ?


#4

Well, you have the following options:

  1. You either define the required settings as system properties upon test start in your ANT build file or POM or whatever build tool you use OR you put the driver-server binaries in your PATH.
  2. You use our DefaultWebDriverFactory class to obtain the driver. Then, the properties defined in your project.properties file will be effective.
  3. You tune your own factory class BrowserDriver to handle the properties defined in your project.properties by yourself. To do so, you can use the class com.xceptance.xlt.api.util.XltProperties as follows:
import com.xceptance.xlt.api.util.XltProperties;

...

final XltProperties props = XltProperties.getInstance();
final String pathToDriverServer = props.getProperty("xlt.webDriver.chrome.pathToDriverServer");
System.setProperty("webdriver.chrome.driver", pathToDriverServer);
...

The API doc for XLT can be found here