I have a scenario where I 1st iframe (i.e parent iframe) which has one button on it and clicking on it another iframe gets open (child iframe). I am able to switch to Parent iframe but when I click on button and tries to interact with Child iframe I'm not able to do it. Can you suggest what should be the better approach to get this type of scenarios working?
My Script:
public class Iframe {
public static void main (String []args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", Constants.Chrome_Driver);
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://automation.cloudaccess.host/administrator");
driver.findElement(By.id("mod-login-username")).sendKeys("admin");
driver.findElement(By.id("mod-login-password")).sendKeys("admin#123");
driver.findElement(By.id("mod-login-password")).submit();
driver.findElement(By.linkText("Components")).click();
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.linkText("Messaging"))).build().perform();
driver.findElement(By.linkText("New Private Message")).click();
driver.findElement(By.className("wf-editor-header")).click();
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[#id=\"jform_message_imgmanager\"]"))).click();
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[contains(#src,'&plugin=imgmanager')]")));
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#id=\"browser-actions\"]/a[#id=\"help\"]"))).click();
driver.switchTo().defaultContent();
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[#id=\"mce_inlinepopups_50_ifr\"]")));
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#id=\"imgmanager.insert\"]/i[#class=\"icon-file\"]"))).click();
driver.quit();
}
}
Error:
Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for frame to be available: By.xpath: //iframe[#id="mce_inlinepopups_50_ifr"] (tried for 20 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:81)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:271)
at testScripts.Iframe.main(Iframe.java:51)
Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.xpath: //iframe[#id="mce_inlinepopups_50_ifr"]
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'vowellt4', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-24-generic', java.version: '1.8.0_171'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.ExpectedConditions.lambda$findElement$0(ExpectedConditions.java:896)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:895)
at org.openqa.selenium.support.ui.ExpectedConditions.access$000(ExpectedConditions.java:44)
at org.openqa.selenium.support.ui.ExpectedConditions$17.apply(ExpectedConditions.java:517)
at org.openqa.selenium.support.ui.ExpectedConditions$17.apply(ExpectedConditions.java:513)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:248)
... 1 more
Just after click on help button , you can try with this code :
driver.switchTo().defaultContent();
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe[src^='/administrator/index.php?option=com_jce&view=help&tmpl=component&lang=en§ion=editor&category=imgmanager&']")));
You are using //iframe[#id=\"mce_inlinepopups_50_ifr\"] this xpath to switch to frame but the problem is the id is getting generated dynamically , so we do not know what will be the id every time we visit the page through automation.
I have simply converted that xpath to a valid and reliable css selector and it is working extremely good at my end.
In case you want to have xpath :
//iframe[contains(#src,'/administrator/index.php?option=com_jce&view=help&tmpl=component&lang=en§ion=editor&category=imgmanager&')]
Hope this will help.
After clicking on the help button, you need to switch to the default content from the parent iframe and then need to navigate to the respective child frame.
Child Frame Xpath needs to be changed as below
Xpath: //*[#class='mceModalContainer']//div[#id='mce_inlinepopups_45_content']//iframe
Modified Working Code:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#id=\"browser-actions\"]/a[#id=\"help\"]"))).click();
driver.switchTo().defaultContent();
new WebDriverWait(driver, 20).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//*[#class='mceModalContainer']//div[#id='mce_inlinepopups_45_content']//iframe")));
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#id='help-menu']//*[#id=\"imgmanager.insert\"]/i[#class=\"icon-file\"]"))).click();
Related
I am trying to login to the webpage for which I am supposed to write test scripts. But the login script fails each time in Safari, although the same script runs well on Chrome.
Error message displayed:
Sep 10, 2018 10:55:06 AM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: mfacode)
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:05:20.749Z'
System info: host: 'iMac.localdomain', ip: 'fe80:0:0:0:1c2b:a0b9:a043:3a94%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities {applicationCacheEnabled: true, browserName: safari, cleanSession: true, cssSelectorsEnabled: true, databaseEnabled: true, handlesAlerts: true, javascriptEnabled: true, locationContextEnabled: false, nativeEvents: true, platform: MAC, platformName: MAC, rotatable: false, version: 13605.3.8, webStorageEnabled: true}
Session ID: E2219A59-8EEE-4380-93B6-77A7DDE289BE
*** Element info: {Using=id, value=mfacode}
The script I am using:
public class LoginSafari {
public static void main(String[] args) {
System.setProperty("webdriver.safari.driver", "/usr/bin/safaridriver");
WebDriver driver= new SafariDriver();
driver.get("https://yapiapp.io/welcome");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.className("auth0-lock-input"))).sendKeys("alaka.goswami#*****.com");
driver.findElement(By.name("password")).sendKeys("*******");
driver.findElement(By.className("auth0-lock-submit")).click();
// WebDriverWait wait=new WebDriverWait(driver, 40);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.id("******")));
// username and password masked//
Is there any way to get passed this or solve this?
This error message...
Sep 10, 2018 10:55:06 AM org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.id: mfacode)
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)
...implies that the WebDriver instance was unable to find any element as per the Locator Strategy you have used.
You need to take care of a couple of things as follows:
Different browser renders the HTML DOM different so you need to construct Locator Strategies to work Cross Browser.
As the username/email and your password field both are on the same page you have to induce WebDriverWait only once.
As you need to invoke sendKeys() method so instead of ExpectedConditions as visibilityOfElementLocated() you need to use the elementToBeClickable() method.
Your effective code block will be:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class yapiapp_login {
public static void main(String[] args) {
System.setProperty("webdriver.safari.driver", "/usr/bin/safaridriver");
WebDriver driver = new SafariDriver();
driver.manage().window().maximize();
driver.get("https://yapiapp.io/welcome");
new WebDriverWait(driver, 30).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.auth0-lock-input[name='username ']"))).sendKeys("alaka.goswami#*****.com");
driver.findElement(By.cssSelector("input.auth0-lock-input[name='password']")).sendKeys("Alakananda Goswami");
}
}
Browser Snapshot(with GeckoDriver/Firefox):
I am practicing Selenium-Webdriver and encounter the issue that the desirable element(text) is visible on web page, but I cannot click on it.
Trying to do check this element is displayed or not by command line "isDisplayed", and the console returns false result. I am a little bit confused that the text(please see the highlight on attached file) on web is visible but why cannot be clickable?
On this case, how can we perform some actions on it? could you please share your ideas and strategy to do.
Thank you so much.
Here is the web page:
http://www.lazada.com.ph/
My code is
System.setProperty("webdriver.chrome.driver", driver_path);
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.get("https://www.lazada.com.ph/");
//Click on Men's Fashion
WebElement loc = driver.findElement(By.xpath("//div[#data-qa-locator='brands-by-category-cats-item']/div[#data-tab-id='2']"));
Actions hover = new Actions(driver);
hover.moveToElement(loc).click().build().perform();
Error log:
false
Exception in thread "main" org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (-2114, -93.0999984741211) is out of bounds of viewport width (1366) and height (659)
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'Lorem', ip: '192.168.30.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\Lorem\AppData\Local\Temp\rust_mozprofile.y3xzzu5rD0i5, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=XP, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=56.0.2, platformVersion=6.3, moz:processID=4724, browserName=firefox, javascriptEnabled=true, platformName=XP}]
Session ID: 893e64ce-b53c-4bec-9f98-14832e4b7151
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:652)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:638)
at basic.Wait.main(Wait.java:41)
The error says it all as follows :
org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: (-2114, -93.0999984741211) is out of bounds of viewport width (1366) and height (659)
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
The WebElement which you are trying to click is Not Visible as it is out of the Viewport. As you have used Actions Class hence it shows MoveTargetOutOfBoundsException
You can consider the following code block to scroll the WebElement within the Viewport first then take help of JavascriptExecutor to click as follows :
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
WebDriver driver = new ChromeDriver();
driver.get("https://www.lazada.com.ph/");
//Click on Men's Fashion
WebElement elem = driver.findElement(By.xpath("//div[#class='c-category-tab c-brands-by-category__tab']/span[#class='c-category-tab__icon c-category-tab__icon_category-fashion']"));
((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView();", elem);
((JavascriptExecutor)driver).executeScript("arguments[0].click();", elem);
It seems that you'r xpath giving more then one element .
try below code .
WebElement loc = driver.findElement(By.xpath("(//div[#data-qa-locator='brands-by-category-cats-item']/div[#data-tab-id='2'])[2]"));
Actions hover = new Actions(driver);
hover.moveToElement(loc).click().build().perform();
The problem is that your xpath return 3 elements. If you try the following code, you could notice this:
//Click on Men's Fashion
List<WebElement> loc = driver.findElements(By.xpath("//div[#data-qa-locator='brands-by-category-cats-item']/div[#data-tab-id='2']"));
System.out.println(loc.size());
int i=1;
for(WebElement we :loc)
{
System.out.println("innerText:" + we.getAttribute("innerText"));
System.out.println("getLocation: " + we.getLocation());
System.out.println("getText: " + we.getText());
System.out.println("getSize: " + we.getSize());
if(we.getText().contains("Men's Fashion"))
{
we.click();
}
System.out.println("------------ "+i+" -------------");
i++;
}
The output is:
3
innerText:Men's Fashion
getLocation: (-2210, 838)
getText:
getSize: (141, 118)
------------ 1 -------------
innerText:Men's Fashion
getLocation: (178, 838)
getText: Men's Fashion
getSize: (141, 118)
------------ 2 -------------
innerText:Men's Fashion
getLocation: (2567, 838)
getText:
getSize: (141, 118)
------------ 3 -------------
If you click the element with getText=Men's Fashion it works.
To be honest I don't know why the xpath return 3 elements. I hope someone give the answer.
There are so many ways to reach to this element. couple more below.
//span[#data-id=4]
//span[#data-tracking-nav-header="Men's Fashion"]
I am unable to run the basic selenium script which contains the HtmlUnitDriver. If I try to run the code I get the following error.
Code:
public class SampleUnitDriver
{
public static void main(String[] args) throws Exception
{
HtmlUnitDriver unitDriver = new HtmlUnitDriver();
unitDriver.get("http://google.com");
System.out.println("Title of the page is -> " + unitDriver.getTitle());
Thread.sleep(3000L);
WebElement searchBox = unitDriver.findElement(By.className("gsfi"));
searchBox.sendKeys("Selenium");
WebElement button = unitDriver.findElement(By.name("gbqfba"));
button.click();
System.out.println("Title of the page is -> " + unitDriver.getTitle());
}
}
Error:
Title of the page is -> Google
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Returned node was not a DOM element
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'user-PC', ip: '192.168.1.52', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51'
Driver info: driver.version: SampleUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByCssSelector(HtmlUnitDriver.java:1060)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByClassName(HtmlUnitDriver.java:1032)
at org.openqa.selenium.By$ByClassName.findElement(By.java:391)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1725)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1721)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1367)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1721)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:606)
at com.digitalmqc.automation.action.SampleUnitDriver.main(SampleUnitDriver.java:16)
The class name gsfi of the input box is generated by javascript so you have 2 options:
Easy One: Just select it by using the id lst-ib
Better One: Wait for the element to be fully interactive. The reason behind this one being better is that you are trying to input text into the box which javascript plays a role. The former option may throw some unexpected errors.
I'm using Selenium 2.2.
I am trying to click on elements which are not displayed at first, but become visible
during the test. At first sometimes the webdriver seemed to work too fast so the Elements were not visible in time resulting in ElementNotVisibleExceptions. I added WebDriverWait to wait for these elements to become visible/clickable. But now I'm getting this random error when using
WebDriverWait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id")));
same for
WebDriverWait.until(ExpectedConditions.elementToBeClickable(By.id("id")));
here is the stacktrace
org.openqa.selenium.WebDriverException: Error determining if element is displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 219 milliseconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:59'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1 build 2600 Service Pack 3', java.version: '1.6.0'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:170)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:123)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:438)
at org.openqa.selenium.remote.RemoteWebElement.isDisplayed(RemoteWebElement.java:280)
at org.openqa.selenium.support.ui.ExpectedConditions.elementIfVisible(ExpectedConditions.java:136)
at org.openqa.selenium.support.ui.ExpectedConditions.access$1(ExpectedConditions.java:135)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:106)
at org.openqa.selenium.support.ui.ExpectedConditions$4.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.ExpectedConditions$11.apply(ExpectedConditions.java:252)
at org.openqa.selenium.support.ui.ExpectedConditions$11.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:201)
at MyTest.myTest(MyTest.java:xx)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
This only happens sometimes. Ignoring the WebDriverException might solve this problem, but that doesn't seem like a clean solution. It can't be a timeout issue because i tried setting my timeout limit to a minute and more and it still fails after a couple of milliseconds.
Anybody got a clean solution to that?
Thanks in advance
Edit: btw. I'm using the InternetExplorerDriver
Make sure page has only one modalPanel. Try get visible panel (java):
public WebElement getVisibleModalPanel(){
for (WebElement element : driver.findElements(By.cssSelector('csslocator'))) {
if (element.isDisplayed()) {
return element;
}
}
return null;
}
Implement wait for such thing:
(new WebDriverWait(getDriver(), timeout, 400)).ignoring(StaleElementReferenceException.class).until(
new ExpectedCondition<Boolean>() {
#Override
public Boolean apply(WebDriver driver) {
for (WebElement element : driver.findElements(By.cssSelector(locator))) {
if (element.isDisplayed()) {
return true;
}
}
return false;
}
});
I'm using the 2.4.0 selenium server in hub mode with two nodes each with 5 instances of Internet explorer (IE8 on win7) - this is all running on the same Win7 machine
The following code throws the exception on the final call to FindElements on the RemoteWebDriver
_driver.Navigate().GoToUrl(#"http://devrsql714/webpages/parentview.aspx");
var wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 40));
wait.Until(d => d.FindElement(By.ClassName("TitleAlternative")));
Console.WriteLine(string.Format("Window title: {0}", _driver.Title));
var element = _driver.FindElementById("txtLessonID");
element.SendKeys("13814");
var button = _driver.FindElementById("btnLessonID");
button.Click();
wait = new WebDriverWait(_driver, new TimeSpan(0, 0, 40));
var link = wait.Until(d => d.Title.Contains("01652-06-A"));
Console.WriteLine(string.Format("Window title: {0}", _driver.Title));
Assert.IsTrue(_driver.Title.Contains("01652"));
Console.WriteLine(string.Format("page source: {0}", _driver.PageSource));
_driver.FindElementsByTagName("DIV");
I can see the browser load, navigate, fillin the text box and click the button - the page refreshes the title changes - the assert passes (this is running in MbUnit with Gallio)
but the subsequent call to _driver.FindElementsByTagName throws the exception below - I added waits in case that was the issue and any find elements results in the same exception
what am I doing wrong? - other properties on the driver work such as title and page source (which has the excepted content)
Note the same code but swapping the RemoteWebDriver for a local InternetExplorerDriver does not throw the exception
In both cases capabilities were set to ignore protect mode:
DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();
capabilities.Platform = new Platform(PlatformType.Any);
capabilities.SetCapability("ignoreProtectedModeSettings", true);
Execute
OpenQA.Selenium.StaleElementReferenceException: Element specified by 'id' is no longer valid (WARNING: The server did not provide any stacktrace information)
Build info: version: '2.4.0', revision: '13337', time: '2011-08-12 09:57:13'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 948
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 805
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElements(String mechanism, String value) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 851
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementsByTagName(String tagName) in c:\Projects\WebDriver\trunk\dotnet\src\WebDriver\Remote\RemoteWebDriver.cs:line 622
at SeleniumTests.DemoTest.AnotherTest()
This is apparently a bug in version 2.4.0 of the selenium server. Downgrading to 2.3.0 might make the problem go away. See this thread on the selenium-users mailing list for more information.