第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

org.openqa.selenium.NoSuchElementException

org.openqa.selenium.NoSuchElementException

慕桂英546537 2021-06-21 17:01:53
我使用 Internet Explorer 和 Firefox 使用 Selenium Web 驅動程序在 JAVA 中編寫了以下代碼。每次我都遇到同樣的錯誤。嘗試使用“id”和“xpath”方法,但仍然失敗。也嘗試添加一些延遲,仍然不起作用。我的 Firefox JAVA 代碼:package ieconnector;import java.util.concurrent.TimeUnit;import org.openqa.selenium.By;import org.openqa.selenium.Capabilities;import org.openqa.selenium.WebDriver;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.remote.RemoteWebDriver;public class FireFoxConnector {public static void main(String[] args) {    try{    GetBrowserProperty gbp = new GetBrowserProperty();    System.setProperty("webdriver.ie.driver",gbp.getIeConnection());    System.setProperty("webdriver.gecko.driver","D:\\softwares\\Selenium\\geckodriver-v0.21.0-win64\\geckodriver.exe");    WebDriver wb = new FirefoxDriver();    Capabilities caps = ((RemoteWebDriver) wb).getCapabilities();    System.out.println("Caps is "+caps);    wb.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);    //wb.navigate().to("https://somewebsite.com:22222/SSO/ui/SSOLogin.jsp");    wb.get("https://somewebsite.com:22222/SSO/ui/SSOLogin.jsp");    wb.manage().deleteAllCookies();    wb.manage().window().maximize();    //wb.findElement(By.id("usertxt")).sendKeys(("user").toUpperCase());    //wb.findElement(By.className("passtxt")).sendKeys("password");    //WebDriverWait wait = new WebDriverWait(wb,10);    //WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("usertxt")));    wb.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);    //wb.findElement(By.id("usertxt")).sendKeys("USER");    wb.findElement(By.xpath("//*[@id='usertxt']")).sendKeys("USER");    System.out.println("Testing is successful");} catch (Exception e) {    e.printStackTrace();}}}以下是我在 IE/Firefox 中的開發(fā)人員工具中的 HTML 代碼的屏幕截圖。
查看完整描述

1 回答

?
飲歌長嘯

TA貢獻1951條經驗 獲得超3個贊

根據您共享的用于定位用戶 ID字段的 HTML,您可以使用以下解決方案:

  • cssSelector

    wb.findElement(By.cssSelector("input.txtbox#usertxt")).sendKeys("USER");
  • xpath

    wb.findElement(By.xpath("//input[@class='txtbox' and @id='usertxt']")).sendKeys("USER");



查看完整回答
反對 回復 2021-06-23
  • 1 回答
  • 0 關注
  • 176 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號