首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Selenium异常错误:找不到元素id=fname

Selenium异常错误:找不到元素id=fname
EN

Stack Overflow用户
提问于 2012-04-27 10:39:45
回答 1查看 2.7K关注 0票数 0

在这个分区selenium记录的代码中,当我使用JUnit在eclipse中运行它时,它显示的是错误元素id= fname没有找到。

包装com.example.tests;

导入com.Thinghtworks.Selenium。*;

进口java.util.regex.Pattern;

公共类msFsitRegistration扩展SeleneseTestCase {

代码语言:javascript
复制
public void setUp() throws Exception {
    setUp("http://192.168.1.146/fsit-mis/index.php?route=common/login", "*chrome");
}
public void testMsFsitRegistration() throws Exception {
    selenium.open("/fsit-mis/index.php?route=common/login");
    selenium.type("name=username", "admin");
    selenium.type("name=password", "admin");
    selenium.click("css=span.button_middle");
    Thread.sleep(5000);
    selenium.useXpathLibrary("xpath=(//a[contains(text(),'Employee Registration')])[2]");
    selenium.open("fsit-mis/index.php?route=employee/emp_registration");
    Thread.sleep(5000);
    selenium.waitForPageToLoad("30000");
    selenium.type("id=fname", "Shiraz");
    selenium.type("id=lname", "A Ansari");
    selenium.type("id=ecode", "FSIT-125");
    selenium.type("id=uname", "shiraz");
    selenium.type("id=password", "shiraz");
    selenium.type("id=confirm", "shiraz");
    selenium.type("id=email", "shijju@gmail.com");
    selenium.select("id=status", "label=ACTIVE");
    selenium.select("id=usrGroup", "label=Fortune Soft");
    selenium.click("xpath=(//input[@name='gender'])[2]");
    Thread.sleep(5000);
    selenium.type("id=mobile", "8088762599");
    selenium.click("id=doj");
    Thread.sleep(5000);
    selenium.click("link=1");
    Thread.sleep(5000);
    selenium.click("id=dob");
    Thread.sleep(5000);
    selenium.click("link=31");
    Thread.sleep(5000);
    selenium.select("id=designation", "label=Test Engineer");
    selenium.click("css=option[value=\"265\"]");
    Thread.sleep(5000);
    selenium.select("id=department", "label=Software Testing");
    selenium.click("id=insert");
    Thread.sleep(5000);
    selenium.waitForPageToLoad("30000");
    selenium.type("id=mobile", "8088762598");
    selenium.click("id=insert");
    Thread.sleep(5000);
    assertEquals("Password Contain Atleast 5 element", selenium.getAlert());
    selenium.click("id=password");
    Thread.sleep(5000);
    selenium.type("id=password", "shiraz");
    selenium.type("id=confirm", "shiraz");
    selenium.click("id=insert");
    Thread.sleep(5000);
    selenium.waitForPageToLoad("30000");
}

}

请尽快帮我。

EN

回答 1

Stack Overflow用户

发布于 2012-04-27 10:49:52

删除所有Thread.sleep(5000);命令。插入selenium.waitForCondition("selenium.isElementPresent('element_locator')", "5000");,例如selenium.waitForCondition("selenium.isElementPresent('id=fname')", "5000");

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10349138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档