Last night that suite ran fine with Chrome, but the suite before it
had the same problem. Since it is failing at the call to create the
RemoteWebDriver instance, I can't see how it can be destroyed, because
it hasn't yet been created! #8^(
This same code is working for 4 different version of IE and four
different versions of FF, and mostly works for Chrome too. Just every
so often it has this failure where it does not create the
RemoteWebDriver object. Based on what I see in the log file it seems
I don't need to set the --ignore-certificate-errors in the
capabilities object that I pass, because it is now the default. I am
not sure if having it defined twice would cause a problem.
Here is the code for the method that starts the task:
public DOTN_Helper(TestParameters testParameters) throws Exception
{
String str;
org.openqa.selenium.remote.DesiredCapabilities capability;
String[] chromeSwitches =
{
"--ignore-certificate-errors"
};
FirefoxProfile ffProfile;
setTestParams(testParameters);
testNG = testParameters.testNG;
switch (Parser.findString(browserName, BROWSERS))
{
case 0:
capability = DesiredCapabilities.firefox();
str = "Firefox" + browserVersion + ".profile";
ffProfile = new FirefoxProfile(new File(str));
capability.setCapability(FirefoxDriver.PROFILE,
ffProfile);
browser = FIREFOX;
break;
case 1:
capability = DesiredCapabilities.internetExplorer();
browser = INTERNET_EXPLORER;
break;
case 2:
capability = DesiredCapabilities.chrome();
capability.setCapability("chrome.switches",
Arrays.asList(chromeSwitches));
//capability.setCapability("chrome.binary",
// "C:\\Program Files\\Google\\Google Chrome\
\chrome.exe");
browser = CHROME;
break;
case 3:
capability = DesiredCapabilities.htmlUnit();
capability.setJavascriptEnabled(true); // Off by
default for htmlUnit
browser = HTML_UNIT;
break;
case 4:
capability = DesiredCapabilities.opera();
capability.setCapability("opera.logging.level",
"FINE");
browser = OPERA;
break;
default:
throw new Exception("Unknown browser name for
RemoteWebDriver: " +
browserName + ".");
} // switch
if (platform.equalsIgnoreCase("WINDOWS") ||
browserName.equals(
"*iexplore"))
capability.setPlatform(Platform.WINDOWS);
else
capability.setPlatform(Platform.ANY);
capability.setVersion(browserVersion);
Reporter.log("Trying to start test session with: " +
capability.toString(), true);
driver = new RemoteWebDriver(new URL("http://" + host + ":" +
port +
"/wd/hub"), capability);
try
{ // We have a session started, don't leave it as an orphan
now
str = "Information from navigator object in browser:" +
"\nuserAgent: " +
driver.executeScript("return
window.navigator.userAgent") +
"\nappCodeName: " +
driver.executeScript("return
window.navigator.appCodeName") +
"\nappVersion: " +
driver.executeScript("return
window.navigator.appVersion") +
"\nlanguage: " +
driver.executeScript("return
window.navigator.language") +
"\nplatform: " +
driver.executeScript("return
window.navigator.platform") +
"\n";
System.out.print(str);
str = str.replace("\n", "<br />");
Reporter.log(str);
selenium = new WebDriverBackedSelenium(driver,
baseUrlString);
selenium.open(baseUrlString);
} // try
catch (Exception ex)
{ // We had an exception after creating the WebDriver
instance
tearDown(); // Make sure we close the browser down
throw ex; // Now report the exception
} // catch
} // DOTN_Helper */
The testParameters you see there are the command line switches that
were passed when the test suite was invoked. Everything else is
pretty self-explanatory.
I think that to figure this out I need to turn on some more detailed
diagnostics. So I would like to know how to do that. Remember, this
is running unattended at about 1:00AM, so any issue like this I pretty
much need to trap some debug output to catch it in the act.
Mike
On Mar 21, 9:11 am, Rajat Jindal <
rajatjinda...@gmail.com> wrote:
> Not so quite sure, but it looks like the problem with the code that you
> have written. [Is your webdriver object getting destroyed somehow before
> you expect it to get destroyed?] I am running sequential tests using
> webdriver + Chrome daily and never faced such an issue.
>
> If you can provide some insight on how your test suites are designed, we
> can offer better help.
>
> Thanks
> Rajat Jindalhttp://
www.quicksilver1183.com