Petr Kováč
Petr Kováč

Reputation: 395

Selenium IEdriver NoSuchElementException exceptionally

I encountered this kinda behavior with IE selenium driver - I am using TEST CASE code generated by Selenium IDE - within Firefox works fine.

driver.Navigate().GoToUrl(baseURL + "/RZR/1.5.85/ZobrazitReklamaceROB.aspx");
driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_identifikaceROB_rbAIFO")).Click();
driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_identifikaceROB_tbAIFO")).Clear();
driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_identifikaceROB_tbAIFO")).SendKeys("pqrJrJxtt/qUvjhO8=");
driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_identifikaceROB_btnVyhledat")).Click();
driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_identifikaceROB_btnVyhledat")).Click();
//Actions action = new Actions(driver);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Tab);
//action.SendKeys(OpenQA.Selenium.Keys.Enter);

driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_gvPrehled_ctl04_selectButton10168579135")).Click();

With IEDriver however - if i run this code under VS2013

  1. In debug with breakpoints and going through step by step - it does work
  2. If i let test go without stepping and breakpoints then NoSuchElementFindException will occurred at

driver.FindElement(By.Id("ctl00_ContentPlaceHolderMain_identifikaceROB_tbAIFO")).Clear();

in case

  1. This normally happened - test passes moreover each time - however sometimes not with NoSuchElementFindException

Colleagues gave me advice to navigate to components(TB in this case) with tab keys - so far unsuccessful as well, but trying this way.

Using latest update of IE, ZOOM 100%, registry alternation according to selenium webpage, protection mode is set same for all zones.

Any idea or same experience?

Update:

Initialization:

[SetUp]
public void SetupTest()
{

    var options = new InternetExplorerOptions
    {
        IgnoreZoomLevel = true
    };

    driver = new InternetExplorerDriver(".", options);

    baseURL = "http://vm-kzr-dev/";
    verificationErrors = new StringBuilder();
}

Upvotes: 1

Views: 250

Answers (2)

Saifur
Saifur

Reputation: 16201

Here is an issue. You need to disable IE native events.

InternetExplorerOptions options = new InternetExplorerOptions();
options.EnableNativeEvents = false;

See this for understanding how native events is related to IEDriver.

I would also suggest you to remove redundant ignoreZoomLevel and replace that with EnableNativeEvents

var options = new InternetExplorerOptions
{
    EnableNativeEvents = false
};

Upvotes: 1

arisalexis
arisalexis

Reputation: 2210

IE seems to be slower and if the test is passing with Firefox then IE is rendering the page slower in which case you can use

WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.Id("ctl00_ContentPlaceHolderMain_gvPrehled_ctl04_selectButton10168579135")));

Upvotes: 1

Related Questions