Not able to check 2nd checkbox. Getting org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (106, 655)

I am getting WebDriverException while trying to select the 2nd checkbox in the list. I am able to select the 1st check box but on the 2nd time when i am calling my method, the code throwing exception. Please find the method that i am using and exception message below. Note: Any suggestion will be helpful for me.

URL: https://www.snapdeal.com/products/computers-external-hard-drives?so...

Note: Required Capacity i am passing from main(). Lets say we want select 1 TB and 2 TB, then i am call the below method two time with parameter as String value.

Code that i am using,

Views: 109

Attachments:

Reply to This

Replies to This Discussion

Hi Bishnu Prasad,

For the selection of checkbox you have initialized variable i=1 and and in the forEach statement you increment the value by 1 (i++), with which your selection box value is 2 because of this it will select only one checkbox which is second one.

Please change the initialization of i from 1 to 0 and check:

public void capacitySelection(String capacity){
        WebDriverWait wd = new WebDriverWait(driver, 180);
        List<WebElement> cList = wd.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[@data-name='Capacity_s']/div")));
        int i=0;
        for(WebElement we:cList){
            WebElement select= wd.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@data-name='Capacity_s']/div["+ i++ +"]/label")));
            if(select.getText().contains(capacity)){
                select.click();
                break;
        }
    }
}

RSS

Adverts

© 2017   Created by Rosie Sherry.   Powered by

Badges  |  Report an Issue  |  Terms of Service