0

screenshot of the IFrame

Scenarion: After clicking New button it will be disable and then need to input the data in field Name text field. It works in Mozilla but not in IE.

IE version -8 IEDriver -IEDriverServer_x64_2.44.0

user1700354
  • 107
  • 2
  • 3
  • 15

1 Answers1

0

try to use alternative CSS selector approach because:

  • CSS selectors perform far better than Xpath and it is well documented in Selenium community
  • Xpath engines are different in each browser, hence make them inconsistent
  • IE does not have a native xpath engine, therefore selenium injects its own xpath engine for compatibility of its API. Hence we lose the advantage of using native browser features that WebDriver inherently promotes.
  • Xpath tend to become complex and hence make hard to read in my opinion However there are some situations where, you need to use xpath, for example, searching for a parent element or searching element by its text (I wouldn't recommend the later).

More details on performance comparison you can get here

After you start make any actions on the webElements also it better to wait until the whole page renders. Here are some tricks that would help you: 1) waitForPageLoad() method:

public void waitForPageLoad(WebDriver driver_) {

        Wait<WebDriver> wait = new WebDriverWait(driver_, 30);
        wait.until(new Function<WebDriver, Boolean>() {
            public Boolean apply(WebDriver driver) {

                return String
                        .valueOf(((JavascriptExecutor) driver).executeScript("return document.readyState"))
                        .equals("complete");
            }
        });
    }

2) fluentWait method -An implementation of the Wait interface that may have its timeout and polling interval configured on the fly.

 public WebElement fluentWait(WebDriver driver, final By locator) {
        Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
                .withTimeout(30, TimeUnit.SECONDS)
                        // .pollingEvery(5, TimeUnit.SECONDS)
                .pollingEvery(1, TimeUnit.SECONDS)
                        // .ignoring(NoSuchElementException.class);
                .ignoring(org.openqa.selenium.NoSuchElementException.class);

        WebElement foo = wait.until(
                new Function<WebDriver, WebElement>() {
                    public WebElement apply(WebDriver driver) {
                        return driver.findElement(locator);
                    }
                }
        );
        return foo;
    }

once you add these methods you can use following calls:

// css selector of the input field:
String cssSelectorInput="blablabla" 
waitForPageLoad(driver);
WebElement input= fluentWait(driver, By.cssSelector(cssSelectorInput));
input.sendKeys("test name");

..... etc

Hope this helps you.

Community
  • 1
  • 1
eugene.polschikov
  • 7,254
  • 2
  • 31
  • 44