selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Unable to find element

Open atomar09 opened this issue 10 years ago • 3 comments

Meta -

OS: Windows 8.1 Selenium Version: 2.53.0 Browser: IE11 Browser Version: IE 11 64 bit

Expected Behavior -

It's unable to find an element, the code works correctly on both FF and Chrome. This means that element exist on the page.

Actual Behavior -

It throws an exception

Steps to reproduce -

Please run the below code:

package tutorialselenium;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.ie.InternetExplorerDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test;

public class IEIssue { private WebDriver driver; private String baseUrl;

@BeforeClass
public void beforeClass() {
    System.setProperty("webdriver.ie.driver",
            "C:\\Users\\Anil Tomar\\workspace\\SeleniumWD2Tutorial\\libs\\IEDriverServer.exe");
    driver = new InternetExplorerDriver();

    baseUrl = "https://www.expedia.com/";
    // Maximize the browser's window
    driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.get(baseUrl);
}

@Test
public void searchFlights() throws Exception {
            // By id or xpath, it does not work by both
    // WebElement element = driver.findElement(By.id("tab-flight-tab"));
    WebElement element = driver.findElement(By.xpath("//a[@id='tab-flight-tab']"));
    element.click();
}

@AfterClass
public void afterClass() throws Exception {
    driver.quit();
}

}

atomar09 avatar Apr 08 '16 01:04 atomar09

Update @BeforeClass with:

System.setProperty("webdriver.ie.driver",
        "C:\\Users\\Anil Tomar\\workspace\\SeleniumWD2Tutorial\\libs\\IEDriverServer.exe");

DesiredCapabilities capabilities =  DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
capabilities.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);

driver = new InternetExplorerDriver(capabilities);

 baseUrl = "https://www.expedia.com/";
// Maximize the browser's window
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(baseUrl);

mstankovic86 avatar Apr 08 '16 08:04 mstankovic86

i agree with this issue,

humzatufail47-zz avatar May 24 '17 08:05 humzatufail47-zz

Unfortunately it's impossible to use the provided sample to reproduce the issue, the target page does not contain an element By.xpath("//a[@id='tab-flight-tab']"). If the issue is still actual please request reopening it with an updated code sample.

barancev avatar Jul 14 '19 09:07 barancev