How to select an item from the dropdown list through selenium webdriver and java
So, I was able to click on the first option getting the XPath from this element:
driver.findElement(By.xpath("//ul[contains(@class,'scrollable')]")).click();
However, this isn't very dynamic as I am unable to click on the second option.
Select from dropdown in selenium-webdriver javascript
In selenium-webdriver JavaScript you don't have "Select" class. You just need to simply click on drop-down option by passing correct css/xpath.
let element = driver.wait(until.elementLocated(By.css(cssLocator)));
element.click();
Selenium - Selecting an item from dropdown list if the values are inside table tags and NOT under option in html
It appears that since the drop down options were inside a < table >, the Select class was unable to identify the list options. So here's what I did:
First click() the dropdown, which opens up the menu:
driver.findElement(By.xpath(".//*[@id='abc01_tbl']/div/div")).click();
Then pass the value using the contains() method and then click() on it.
driver.findElement(By.xpath(".//*[@id='xyz01_tbl']/tbody/tr/td[1][contains(text(),'I am option2')]")).click();
Related Topics
Noclassdeffounderror While Trying to Run My Jar with Java.Exe -Jar...What's Wrong
Java "" Operator for Checking Null - What Is It? (Not Ternary!)
Formatting a String to a Currency Format in Jasper Report
Uninitialized Object VS Object Initialized to Null
Spring 4 - Addresourcehandlers Not Resolving the Static Resources
Self Signed X509 Certificate with Bouncy Castle in Java
Using Bufferedreader.Readline() in a While Loop Properly
How to Find Repeated Characters with a Regex in Java
Java Server with Multiclient Communication
How to Use the Unsigned Integer in Java 8 and Java 9
Spring Batch - Using an Itemwriter with List of Lists
Parsing Nested JSON Data Using Gson
How to Use Urlclassloader to Load a *.Class File
Spring 3 MVC: One-To-Many Within a Dynamic Form (Add/Remove on Create/Update)
Jtable + Sorting Specific Field
How to Create New Xml File from Existing Database in Postgresql Database Using Java