I am trying to select the filter sub-section ( Left panel) in flip kart page. I am trying to expand "TYPE" section but I could not do it...

 WebDriver driver = new ChromeDriver();
    Actions a = new Actions(driver);

below is sample code ... Your inputs please

  • What us the error you are getting?
    – kirbycope
    Jun 4 '17 at 13:53
  • Not Getting error, It's selecting an element from Filter options ( I think first available element in filter section). I am expecting to click on the "Type" sub-section in filter which enables me to select options under it.
    Jun 4 '17 at 16:24

Using the DevTool's Console in Chrome, I can confirm this selector works:

document.querySelector("#container > div > div > div > div > div > div > div > div:nth-child(7) > section > div > div")

So, in Selenium code:

WebDriver element = driver.findElement(By.cssSelector("#container > div > div > div > div > div > div > div > div:nth-child(7) > section > div > div"));

One thing I noticed is that the element is not visible in the ViewPort. So, you'll likely need to do one of the following solutions:

Scroll to the element before clicking it

((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

and/or Click via JavaScript

((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
  • Thanks, It worked for me... I would prefer to use scrollIntoView so that action will be visible.
    Jun 11 '17 at 2:57

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.