0

I have tried all the possible things. also, tried searching over tried different combinations and variations. I can get the element clicked which opens the dropdown. but i am not able to select an option in it. I tried with actions, sendkeys, keys.down/enter and multiple things as well. however, it didn't help. That's the only thing I am stuck on.

//selecting office

driver.findElement(By.id("DG5QEPn")).click();

// attempt with actions
Actions actions = new Actions(driver);
actions.moveToElement(driver.findElement(By.xpath("//*[@id="DG5QEPn"]/div/div/div1/div1"))).click();

// attempt with sendKeys
driver.findElement(By.id("DG5QEPn")).click();

driver.findElement(By.id("DG5QEPn")).sendKeys("RTP HQ"); 

// attempt with Keys.Down and Keys.Enter
driver.findElement(By.id("DG5QEPn")).sendKeys(Keys.Down); 
driver.findElement(By.id("DG5QEPn")).sendKeys(Keys.Enter);

enter image description here

  • It will be good if you give HTML DOM code instead of screenshot – Mohamed Sulaimaan Sheriff Jul 11 at 1:37
  • <div class="css-fx5u20 react-select__value-container react-select__value-container--has-value"><div class="css-o6m1t9-singleValue react-select__single-value">RTP HQ</div><div class="css-1g6gooi"><div class="react-select__input" style="display: inline-block;"><input autocapitalize="none" autocomplete="off" autocorrect="off" id="select_input_Office" spellcheck="false" tabindex="0" type="text" aria- – Safaee Jul 13 at 15:08
  • Please add this in your answer – Mohamed Sulaimaan Sheriff Jul 13 at 16:11
0

Try to use javascript click which will click on the element given it is present unlike the webdriver selenium click which needs the element to be displayed first.

driver.executeScript("arguments[0].click();", element)
| improve this answer | |
0

Below code worked for me

WebElement selectMyElement = driver.findElement(By.id("DG5QEPn"));

selectMyElement.click();

Thread.sleep(4000);

Actions keyDown = new Actions(driver); keyDown.sendKeys(Keys.chord(Keys.DOWN, Keys.DOWN, Keys.ENTER)).perform();

| improve this answer | |

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.