2012-04-27 48 views
0

在這種particlular硒當我在eclipse使用JUnit它表示Me錯誤元素ID運行它= FNAME沒有發現硒異常錯誤:元素ID = FNAME沒有發現

包com.example.tests記錄的代碼;

import com.thoughtworks.selenium。*;

import java.util.regex.Pattern;

公共類msFsitRegistration擴展SeleneseTestCase {

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", "[email protected]"); 
    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"); 
} 

}

請儘快幫我儘可能..

回答

1

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