var newWindow = WebDriver.WindowHandles[1];
WebDriver.SwitchTo().Window(newWindow);
The problem is that i get an error like this :
System.InvalidOperationException: respond.session.getWindow() is null
at
OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response
errorResponse)
When i run this test on my computer it works, but on the build server
at my job it doesn't, and the error is thrown.
This leads me to believe that the error is because the build server is
slower, and therefore the WindowHandle isn't created when i try to
switch to it.
I added Thread.Sleep(), and it fixed the problem, but I was wondering
if there was a better way to fix this problem ??
public void waitForNumberOfWindowsToEqual(final int numberOfWindows) {
new WebDriverWait(driver, timeout) {
}.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return (driver.getWindowHandles().size() == numberOfWindows);
}
});
}
Set the number of windows you are expecting using the above function and
then use the line of code you have shown below.
--
You received this message because you are subscribed to the Google Groups
"Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to
selenium-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/selenium-users?hl=en.
--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
If you have received this email in error please notify postm...@ardescosolutions.com
Thanks!
> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> --
> This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
>
> If you have received this email in error please notify postmas...@ardescosolutions.com
For more options, visit this group at
http://groups.google.com/group/selenium-users?hl=en.