ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

RemoteWebDriver.findElement(By) error message should include selector #988

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Selenium 2.44.0

When RemoteWebDriver.findElement(By) fails, it throws:

org.openqa.selenium.NoSuchElementException: no such element

Expected behavior: error message should include the CSS or XPath selector that 
failed to match.

Original issue reported on code.google.com by cow...@bbs.darktech.org on 30 Nov 2014 at 1:13

GoogleCodeExporter commented 9 years ago
Please provide a complete executable scenario and a complete sample page to 
reproduce the issue

Usually Selenium prints the locator and the exception message looks like this:

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable 
to find element with css selector == ifra

So you must be faced an edge case that is not properly covered.

Original comment by barancev on 1 Dec 2014 at 6:43

GoogleCodeExporter commented 9 years ago
barancev,

I'd like to attach a self-contained Maven testcase but the issue tracker says 
"Issue attachment storage quota exceeded" below. What do you recommend?

Original comment by cow...@bbs.darktech.org on 1 Dec 2014 at 6:47

GoogleCodeExporter commented 9 years ago
@barancev,

Here is a self-contained testcase for your review:

import java.io.File;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Main {

    public static void main(String[] args) throws IOException {
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();
        ChromeDriverService service = new ChromeDriverService.Builder()
                .usingDriverExecutable(new File("selenium-driver/windows/googlechrome/64bit/2.10/chromedriver.exe"))
                .usingAnyFreePort()
                .build();
        service.start();
        WebDriver driver = new RemoteWebDriver(service.getUrl(), capabilities);
        driver.findElement(By.cssSelector("non-existent"));
    }
}

The only value you need to update is the path to chromedriver.

I await your response.

Original comment by cow...@bbs.darktech.org on 3 Dec 2014 at 2:52

GoogleCodeExporter commented 9 years ago
On a side-note, someone posted a blog entry last year complaining about this 
very same issue: 
http://rlogiacco.wordpress.com/2013/12/02/selenium-and-the-holy-search-for-lost-
element/

Original comment by cow...@bbs.darktech.org on 3 Dec 2014 at 2:53

GoogleCodeExporter commented 9 years ago
chromedriver, that was the missing part of the puzzle

Original comment by barancev on 3 Dec 2014 at 3:54

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:18