1
我试图找到一个标签,这是一个PNG图像。我有该标签的来源。但我已经试过follwoing选项:无法找到使用webdriver的元素
1)
WebElement image = driver.findElement(By.id("x", "a"));
String src = image.getAttribute("src");
src.contains("x.png");
2)
WebElement image = driver.findElement(By.name("x"));
我无法做到发现it.its不是一个隐藏的元素,以及...任何输入????将不胜感激......
你为什么要叫'By.id'以2个参数的时候,只需要1?标签的来源是什么样的? –
^他说什么。^...'By.id()'只接受一个参数,上面的代码也不以任何方式使用'src.contains()'。你也可以在一行中得到它'By.xpath(“// img [contains(@ src,'x.png')]”)'。您是否尝试过[隐式](http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html)或[explicit](http:// selenium。 googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html)[wait](http://seleniumhq.org/docs/04_webdriver_advanced.html#explicit-and-implicit-等待)?这是最常见的解决方案。 –