2012-02-09 61 views
1

蔭使用WebDriverBackedSelenium和tyring運行我的RC情況下,我得到以下錯誤,WebDriverBackedSelenium -getElementTagName執行失敗的錯誤

錯誤:

com.thoughtworks.selenium.SeleniumException:getElementTagName執行失敗;元素不在高速緩存中Backtrace:0x43f80e 0x4320ae 0x4327e1 0x4336dc 0x4347ba 0x4250e9 0x42ca6c 0x41a597 0x484df8 0x4861f2 0x486491 start_thread [0x7f615369dd8c] 0x7f6150cde04d(警告:服務器沒有提供任何堆棧跟蹤信息);持續時間或超時時間:25毫秒構建信息:版本:'2.6.0',修訂:'13840',時間:'2011-09-13 14:55:30'系統信息:os.name:'Linux',os。 arch:'amd64',os.version:'2.6.38-10-generic',java.version:'1.6.0_22'驅動程序信息:driver.version:RemoteWebDriver,位於org.openqa.selenium.internal.seleniumemulation.SeleneseCommand。申請(SeleneseCommand.java:42)

代碼I使用:

DesiredCapabilities能力= DesiredCapabilities.chrome();

Selenium selenium = null; 

    capabilities.setCapability("chrome.binary", "/opt/google/chrome/google-chrome"); 

    WebDriver driver = new ChromeDriver(capabilities); 
    selenium = new WebDriverBackedSelenium(driver,getCurrentSetupURL()); 

selenium.type(「id」,「value」) - 在這行錯誤被拋出!

回答

1

您必須指定要寫入的ID。假設您嘗試登錄用戶。因此,在大多數情況下,登錄頁面的HTML看起來像這樣:

<input type="text" id="username"></input> 
<input type="password" id="password"></input> 

爲了在填補這些,命令是這樣的:

selenium.type("id=username", "username"); 
selenium.type("id=password", "password"); 

上面的代碼將進入價值username到用戶名字段和值password到密碼字段

如果你從來沒有指定什麼idvalue在你的代碼的意思,那麼obvipously你得到的NullPointerException

+0

你的意思是說我應該使用selenium.type(「id = username」,「username」);而不是selenium.type(「username」,「」); – sasikumar 2012-02-10 06:03:28

+0

是的。或者更好的方法是在您的瀏覽器中安裝selenium IDE並記錄它的測試用例。然後導出到您的項目 – 2012-02-10 06:27:56

相關問題