【发布时间】:2015-10-05 15:42:39
【问题描述】:
我有以下问题,在执行登录后,系统加载主页,大概需要 5 秒,所以在那之后,脚本应该输入超过 3 个字段并执行一个选项卡以获取更多信息,但是问题是有时有效,有时无效,在 5 次机会中,只有一个有效,我不知道是不是关于获取所有字段的时间或类似的东西,我正在使用 IE 9,因为该应用程序仅适用于 IE
代码如下: `
System.setProperty("webdriver.ie.driver","C:\\Apps\\eclipse\\IEDriverServer.ex;
WebDriver driver = new InternetExplorerDriver();
driver.get("http://15.192.41.95/Cabina/asp/Login.asp");
WebElement text1 = driver.findElement(By.id("text1"));
text1.sendKeys("xxxx");
WebElement password1 = driver.findElement(By.id("password1"));
password1.sendKeys("xxxx");
WebElement aceptar = driver.findElement(By.id("ok1"));
aceptar.click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.switchTo().frame(driver.findElement(By.name("menu")));
WebElement txtNumPolSol = driver.findElement (By.id("txtNumPolSol"));
txtNumPolSol.sendKeys("877885");
WebElement Text8 = driver.findElement(By.name("txtNumofic"));
Text8.sendKeys("228");
WebElement txtCveInc = driver.findElement(By.name("txtCveInc"));
txtCveInc.sendKeys("1");
WebElement clave = driver.findElement(By.id("txtCveInc"));
clave.sendKeys(Keys.TAB);
driver.switchTo().frame(driver.findElement(By.name("dest")));
WebElement txtNomrepo = driver.findElement(By.id("txtNomrepo"));
txtNomrepo.sendKeys("Jorge Villarreal");
driver.findElement(By.id("txtRelacion")).sendKeys("Conductor");
WebElement txtTelrepo = driver.findElement(By.id("txtTelrepo"));
txtTelrepo.sendKeys("83029090");`
这里有不同的问题:
1) 无法找到名称 == txtOficina 的元素
2) 元素不再有效
3) 找不到 id == txtCveInc 的元素(该字段在那里)
4) 找不到名称为 == txtCveInc 的元素(该字段在那里)
系统获取问题的步骤是:
1) 登录(到目前为止一切顺利) 2)系统加载主页面(页面有框架并在5秒内获取所有字段......) 3) txtNumPolSol、txtNumofic 和 txtCveInc 上的脚本类型(大部分问题在最后两个字段) 4)脚本执行选项卡 5)系统加载有关记录的一些信息,脚本继续...... 注意:几乎所有问题都发生在第 3 步...
感谢您的反馈!
【问题讨论】:
-
我看不到您尝试在测试中查找名称为
txtOficina的元素。我看不到您试图在测试中查找名称为txtCveInc的元素。元素不再有效是什么意思?如果它是一个 StaleElemenetReferenceException 添加等待不会做任何事情。如果没有标记,我们将会遇到问题,因为您显然正在与框架进行交互。最可能的问题是您在错误的框架中搜索元素。
标签: java internet-explorer webdriver webtest