51Testing软件测试论坛
标题:
frame下无法定位到“添加”按钮
[打印本页]
作者:
beryle
时间:
2014-12-8 15:51
标题:
frame下无法定位到“添加”按钮
定位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中的元素?
作者:
zhanghl820716
时间:
2014-12-9 16:02
确认一个你要测试的页面是否为嵌套的三级和四级页面吧,如果是的话对象不好识别的,这也是我遇到的问题,一直也没有很好的解决方案
作者:
joykao
时间:
2014-12-9 18:21
iframe之间是要切换的
/**
* Switch frames
* @param frame
*/
public static void switchToFrame(String frame) {
driver.switchTo().defaultContent().switchTo().frame(frame);
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2