【问题标题】:getting Not clickable exception (Element <select class="form-control" name="statusDropdown"> is not clickable at point)获取不可点击异常(元素 <select class="form-control" name="statusDropdown"> 点不可点击)
【发布时间】:2020-11-02 10:32:08
【问题描述】:

1.实际上过去 2 天我试图解决这个异常,但它仍然无法正常工作。因此,即使我使用正确的 xpath 但我仍然遇到此异常,请提出可能是什么问题。

  1. 我在下面使用 xPath
deliveryChannel=//statusdropdown[@id="deliveryChannelField"]//select  

对于这个 xpath 我得到了异常,这个 Xpath 我在测试中使用 case (Test(priority = 4))

printStatus = //statusdropdown[@id="releaseStatusDropDown"]//select

这里没有例外

@Test(priority = 4)
    public void deliveryChannel() throws InterruptedException {
        wait = new WebDriverWait(driver, 10);
        
        String getDeliveryChannel = sftpCon.deliveryChannel("Search Criteria", 0);
    //WebElement deliveryChannelDropDown = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(prop.getProperty("deliveryChannel"))));
        WebElement deliveryChannelDropDown = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(prop.getProperty("deleverysize"))));
        System.out.println("Delevery Channel Text = "+deliveryChannelDropDown.getText());
        select = new Select(deliveryChannelDropDown);
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        List<WebElement> listSelectApp = select.getOptions();
        for (int i = 0; i < listSelectApp.size(); i++) {
            String app = listSelectApp.get(i).getText();
            if (getDeliveryChannel.contains(app)) {
                listSelectApp.get(i).click();
            }
        }
    }

    @Test(priority = 5, retryAnalyzer = com.brcc.tool.RetryFailedTestCases.RetryTestCases.class)
    public void getPrintStatus() throws InterruptedException {
        wait = new WebDriverWait(driver, 10);
        String printStatus = sftpCon.deliveryChannel("Search Criteria", 1);
        WebElement printStatusDropDown = wait
                .until(ExpectedConditions.visibilityOfElementLocated(By.xpath(prop.getProperty("printStatus"))));
        select = new Select(printStatusDropDown);
        List<WebElement> listSelectApp = select.getOptions();
        for (int i = 0; i < listSelectApp.size(); i++) {
            String app = listSelectApp.get(i).getText();
            if (printStatus.contains(app)) {
                listSelectApp.get(i).click();
            }
        }
    }

下面是我的 html 元素

<div class="col-md-8">
<statusdropdown id="deliveryChannelField" ng-reflect-selected-status="print" ng-reflect-optional-status="[object Object]" ng-reflect-return-key="delivery_channel_name" ng-reflect-display-key="delivery_channel_description">
<select class="form-control" name="statusDropdown">
<!--bindings={  "ng-reflect-ng-for-of": "[object Object]"
}-->
<option value="print" ng-reflect-value="print">Print</option>
</select>
</statusdropdown>
</div>

【问题讨论】:

  • 你能分享你想要交互的特定元素的 html 元素 dom 吗?
  • 请检查我是否添加了 html 元素
  • 使用 Select 时必须使用带有 select 标签的元素。在 select = new Select(name) 中使用 name="statusDropdown" 元素。

标签: java selenium selenium-webdriver testng


【解决方案1】:

我认为您可以使用elementToBeClickable() 而不是visibilityOfElementLocated()。如果这不起作用,那么我认为该网站有问题,您必须编辑您的问题以提供该网站。

【讨论】:

    猜你喜欢
    • 2016-07-08
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 2018-02-19
    • 2019-08-04
    • 2015-06-13
    • 2019-11-28
    • 1970-01-01
    相关资源
    最近更新 更多