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-等待)?這是最常見的解決方案。 –