【问题标题】:i have two drop downs i need to select a value from both at a time我有两个下拉菜单,我需要一次从两个下拉菜单中选择一个值
【发布时间】:2019-06-11 09:41:55
【问题描述】:

这里有两个下拉菜单,一个是“选择司机”,另一个是“选择汽车”,我需要同时从两个下拉菜单中选择一个值..

      this is for "select Driver" drop down

     new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h1[contains(., 'Dashboard')]")));
     driver.get("https://ecabportal.azurewebsites.net/addassignVechile");
     new WebDriverWait(driver, 20).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@id='load']")));
     new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("span.select2-selection__rendered"))).click();
     new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[contains(., 'Malveena')]"))).click();

    this is for "Select Car" drop down

     new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h1[contains(., 'Dashboard')]")));
     driver.get("https://ecabportal.azurewebsites.net/addassignVechile");
    new WebDriverWait(driver, 20).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@id='load']")));
     new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("span.select2-selection__rendered"))).click();
     new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[contains(., 'X5')]"))).click();

“选择驱动程序”下拉菜单正在工作,但我在控制台中遇到错误,例如“线程“主”org.openqa.selenium.TimeoutException 中的异常:预期条件失败:等待 By.xpath 定位的元素的可见性://h1 [contains(., 'Dashboard')] (尝试 20 秒,间隔 500 毫秒)"

原因:org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//h1[contains(., 'Dashboard')] "}

【问题讨论】:

  • 请任何人帮助我

标签: selenium-webdriver


【解决方案1】:

在这种情况下有两个异常 1) TimeOutException 和 2) NoSuchElementException。在您的情况下,您在显式等待中使用的路径即使在 20 秒后也找不到任何元素。死于这些原因,硒无法找到元素并且它失败了。 您可以在应用程序中手动检查您的路径一次,因为它没有识别任何提供的元素。

谈到异常,当我们使用explicitWait 以及在满足上述条件之前给定时间到期时,将引发TimeOutException。你可以确保你的路径可以解决你的问题..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多