0

I am unable to click on this dropdown.

I tried selecting the dropdown and javascript click and normal click. Waiting for this element to be present also fails.

Please provide the solution for the same.

enter image description here

Below is the code for waitForElement, typeAction etc. Locator type, LocatorName, and data comes from excel file. I have created a hybrid framework.

public static void waitForElement(WebDriver driver, String locator_Type, String locator_Value) {
    WebDriverWait wait = new WebDriverWait(driver,30 );
    if (locator_Type.equalsIgnoreCase("id"))
    {
       wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(locator_Value)));
     // dropdown.click();
    }
    else
        if (locator_Type.equalsIgnoreCase("xpath"))
        {
            wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator_Value)));
        }
            else
                if (locator_Type.equalsIgnoreCase("classname")) {
            wait.until(ExpectedConditions.visibilityOfElementLocated(By.className(locator_Value)));
        }
        }
    public static void typeAction(WebDriver driver, String locator_Type, String locator_Value, String data) {
    if (locator_Type.equalsIgnoreCase("id")) {
        driver.findElement(By.id(locator_Value)).clear();
        driver.findElement(By.id(locator_Value)).sendKeys(data);

    }
    if (locator_Type.equalsIgnoreCase("xpath")) {
        driver.findElement(By.xpath(locator_Type)).clear();
        driver.findElement(By.xpath(locator_Value)).sendKeys(data);
    }
}
    public static void dropDown(WebDriver driver, String locatorType, String locatorValue, String data) {
    if (locatorType.equalsIgnoreCase("id")) {
        new Select(driver.findElement(By.id(locatorValue))).selectByVisibleText(data);

    } else if (locatorType.equalsIgnoreCase("xpath")) {
        new Select(driver.findElement(By.xpath(locatorValue))).selectByVisibleText(data);
    }

public static void clickScript (WebDriver driver, String Locator_Type, String Locator_Value)


        {
            if (Locator_Type.equalsIgnoreCase("id")) {
                WebElement element = driver.findElement(By.id(Locator_Value));
                JavascriptExecutor executor = (JavascriptExecutor) driver;
                executor.executeScript("arguments[0].click();", element);

            } else if (Locator_Type.equalsIgnoreCase("xpath")) {
                WebElement element = driver.findElement(By.xpath(Locator_Value));
                JavascriptExecutor executor = (JavascriptExecutor) driver;
                executor.executeScript("arguments[0].click();", element);

            }
        }
2
  • Posting the source code of the drop down may help people understand your issue Mar 27 '19 at 13:50
  • public static void dropDown(WebDriver driver, String locatorType, String locatorValue, String data) { if (locatorType.equalsIgnoreCase("id")) { new Select(driver.findElement(By.id(locatorValue))).selectByVisibleText(data); } else if (locatorType.equalsIgnoreCase("xpath")) { new Select(driver.findElement(By.xpath(locatorValue))).selectByVisibleText(data); } Mar 28 '19 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.