【发布时间】:2015-12-10 00:46:32
【问题描述】:
我正在测试一个 Angular js 应用程序
当我单击 Web 应用程序上的 UI Kit 链接时,我收到以下错误 -
在 demoaj.Ajapp.main(Ajapp.java:16) 引起: org.openqa.selenium.NoSuchElementException:无法定位元素: {"方法":"xpath","选择器":"html/body/div1/div1/aside/div/div/ul/li[2]/a"} 命令持续时间或超时:51 毫秒 错误,请访问: http://seleniumhq.org/exceptions/no_such_element.html
我是新手,我对这个 AngularJS 做了一些研究
java代码
package demoaj;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Ajapp {
public static void main(String[] args) throws InterruptedException {
WebDriver d=new FirefoxDriver();
d.manage().window().maximize();
d.get("http://iarouse.com/demo/index.html?product=square");
WebDriverWait wait = new WebDriverWait(d, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("html/body/div[1]/div[1]/aside/div/div/ul/li[2]/a"))).click();
//d.findElement(By.xpath("html/body/div[1]/div[1]/aside/div/div/ul/li[2]/a")).click();
}
}
我认为它无法找到元素,因为在 angularjs 中,dom 没有呈现。当我检查页面源时,它没有显示任何东西,在对 angularjs 测试进行一些研究后,所有的东西都被隐藏了,我有几个问题请帮忙,
用于 Angular 应用测试。
- 我想我必须使用量角器?我猜
- 如果我使用量角器,我必须用 javascript 或 jquery 编写代码吗?
- 如果我使用量角器,我可以使用 eclipse ide 或 intellij 在 java 中编写代码吗?
请帮忙,
提前致谢。
【问题讨论】:
标签: java angularjs selenium protractor webdriverjs