請建議點擊方式-Facebook注冊頁面-創建新帳戶按鈕-使用selenium java(不允許右鍵單擊)我嘗試使用此代碼-- https://www.facebook.com/--
WebElement element=driver.findElement(By.id("u_0_2_1a"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
錯誤:org.openqa.selenium.NoSuchElementException:
沒有這樣的元素:無法找到元素:{"method":"css selector","selector":"#u_0_2_1a"}
uj5u.com熱心網友回復:
您正在使用ID可以更改的屬性。因此它沒有拋出這樣的元素。請使用如下的xpath:
//form//a[@role='button'][contains(.,'Create New Account')]
我剛剛測驗了它。有用。下面應該是您的代碼。
WebElement element=driver.findElement(By.xpath("//form//a[@role='button'][contains(.,'Create New Account')]"));
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/488594.html
上一篇:當前背景關系中不存在名稱“ExpectedConditions”
下一篇:遍歷兩個下拉選單并下載檔案
