0

Im automating something and one thing i have issue with is an auto-complete dropdown where im sending a string key to, but then i need to choose from the drop down a value to select it, and I have to actually click on it.

So I wanted to know if its possible after that im sending the key to:

go down one time (with the "down" arrow in the keyboard)

then

click enter

is that possible?

I can use java or scala

thanks

Joe
  • 2,543
  • 3
  • 25
  • 49

2 Answers2

1

Yes you can do that by following code :

WebElement element = driver.findElement(By.id(""); //HERE GIVE ID OF THAT YOUR ELEMENT & YOU CAN DO SENDKEYS WITH IT IF REQUIRE
element.sendKeys(Keys.DOWN); // IT WILL PRESS DOWN KEY
element.sendKeys(Keys.ENTER); // IT WILL PRESS ENTER KEY
Helping Hands
  • 5,292
  • 9
  • 60
  • 127
0

Yes it is possible, see Selenium WebDriver and Selenium Actions Class. e.g. you may try

Java(for Enter Key)

driver.findElement(By.id("Value")).sendKeys(Keys.RETURN);

or

driver.findElement(By.id("Value")).sendKeys(Keys.ENTER);

And for Down

driver.findElement(By.id("Value")).sendKeys(Keys.DOWN);
Learner
  • 5,192
  • 1
  • 24
  • 36