實際上,我提交了一個包含元素名稱觀察者和「2」的網頁。 提交之前我正在改變元素的值,然後提交網頁。在提交相同的頁面將出現包含元素的改變的值。現在,當我試圖通過它的ID訪問這個元素它沒有給我改變的值但它給了我空串。此Selenium中的訪問元素
//for changing the value of element
String a="muthu_snmp";
driver.findElement(By.id("2")).sendKeys(a); // working fine
driver.findElement(By.id("submit")).click();
WebDriverWait wait = new WebDriverWait(driver,30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("2")));
String s=driver.findElement(By.id("2")).getText(); //this is giving me "" ie empty strings.
代碼實際上我想比較,我已經發送的值保存與否。 所以請幫助...
您是否親自檢查了生成的文檔? html對於id =「2」的元素如何看起來像? – luksch