0

I am trying to inspect dropdown in selenium using java which is displayed on the frontend but it is having 'aria-hidden='true' in its source code.. but it is giving me error as 'Element not interactable'. Have tried using below options:

  1. 'WebElement dropdown = wait.until(ExpectedConditions.presenceOfElementLocated'
  2. Select class
  3. Xpath, id & classname

Code snip:

WebDriverWait wait = new WebDriverWait(driver, 10); //First click on dropdown to show options 

WebElement dropdown = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("select[id='lender_id']"))); 

dropdown.click(); //Now find desired option and click

wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("select[id='lender_id']"))).click();

enter image description here

enter image description here

Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
Pooja
  • 1
  • 1
  • 1
    Have you tried clicking it first? please shear your code. – Moshe Slavin Jul 15 '21 at 08:03
  • Can you provide the URL for this? – YaDav MaNish Jul 15 '21 at 08:25
  • @MosheSlavin please find below code for this: WebDriverWait wait = new WebDriverWait(driver, 10); //First click on dropdown to show options WebElement dropdown = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("select[id='lender_id']"))); dropdown.click(); //Now find desired option and click wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("select[id='lender_id']"))).click(); – Pooja Jul 15 '21 at 09:27
  • @YaDavMaNish sorry i cant provide the url for this – Pooja Jul 15 '21 at 09:30
  • @YaDavMaNish i tried using xpath but got the same error – Pooja Jul 15 '21 at 09:32
  • @Pooja can you add to the question the relevant HTML. including the select and options – Moshe Slavin Jul 15 '21 at 11:12
  • @MosheSlavin done please check – Pooja Jul 15 '21 at 11:55

2 Answers2

0

You should use the `Select class.

WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("select[id='lender_id']"))); 

new Select(element).selectByValue(valueToSelect);
Moshe Slavin
  • 5,127
  • 5
  • 23
  • 38
  • tried this but still getting error 'element not interactable: Element is not currently visible and may not be manipulated' – Pooja Jul 20 '21 at 05:30
0

aria-hidden=true attributes indicate that the element and All of its descendants are still visible in the browser, but will be invisible to accessibility tools, check here

WebDriverWait wait = new WebDriverWait(driver, 10);  

WebElement dropdown = 
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[@class='form-group']//select[starts-with(@id,'lender_id') and starts-with(@name,'lender_id')]")); 

Select select = new Select(dropdown);
select.selectByValue("value");
YaDav MaNish
  • 1,260
  • 2
  • 12
  • 20