Issue
I need to confirm if selected value from combobox is correct and I have this code, but it just print the selected value. I want to compare with a text typed and if the selected value is the correct, the test should pass
I'm using Selenium with Java.
Select select = new Select(driver.findElement(By.id ("koopon-produto-select-produto-
especifico-calculos-icms")));
WebElement option = select.getFirstSelectedOption();
String defaultItem = option.getText();
System.out.println(defaultItem);
Solution
Can you check the below code, if it help
Select select = new Select(driver.findElement(By.id("koopon-produto-
select-produto-especifico-calculos-icms")));
String text = select.getFirstSelectedOption().getText();
String result = (text.equals(("test")))?"Pass":"Fail";
System.out.println(result);
Answered By - YaDav MaNish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.