TA的每日心情 | 开心 2015-8-5 13:21 |
---|
签到天数: 7 天 连续签到: 2 天 [LV.3]测试连长
|
定位iframe下的“添加”按钮:
(见图)
代码如下:
String URL = driver.findElement(By.name("workspace")).getAttribute("src").toString();
driver.get(URL);
driver.findElement(By.xpath("/html/body/div[1]/div[3]/div/a[1]"));
//WebElement btn1 = driver.findElement(By.cssSelector("iconButton opera_971"));
// btn1.click();
// driver.findElement(By.xpath( "//a[@onclick = 'add()']" )).click();
错误如下:
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"/html/body/div[1]/div[3]/div/a[1]"}
Command duration or timeout: 10 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:58'
System info: host: '0308-PC', ip: '172.230.140.39', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=34.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 95a29865-3ca8-4b39-98f1-a1f02fd99f9f
为什么定位不到frame中的元素?
|
|