Quality Testing

Quality is delighting customers

How to select the dropdown value (Image) in Selenium Webdriver ?

How to select the dropdown value (Image) in Selenium Webdriver ?

Can any one provide the code...

Refer below screenshot:

Views: 974

Reply to This

Replies to This Discussion

Use this code

dropdown.selectByVisibleText("Image ");

for selecting the value from drop down >> (image)

I have tried " dropdown.selectByVisibleText("Image ");" . But it is not working.

You can do like this:
Generic method eg. Browser.class
public static void dropDown(WebElement Element, String text){
Select dropdown = new Select(Element);
dropdown.selectByVisibleText(text);
}

In main script just call the method:
Browser.dropDown(driver.findElement(By.id(""), "image");

In generic method try with index, or By value.

first click on the dropdown then wait for image to appear
then click on the image

Dont use select here it wont work

I have tried like this: 

driver.findElement(By.xpath("//div[@id='contentwrapper']/div[3]/div/div[3]/div[5]/div/div[3]/div[2]/div/div/div/span/input")).click();

driver.findElement(By.xpath("//div[@id='contentwrapper']/div[3]/div/div[3]/div[5]/div/div[3]/div[2]/div/div/div/span/input")).sendKeys("Image");

driver.findElement(By.cssSelector(".caption-sec.ng-binding")).click();

But it is not wokring.

driver.findElement(By.xpath("//div[@id='contentwrapper']/div[3]/div/div[3]/div[5]/div/div[3]/div[2]/div/div/div/span/input")).click();
then put thread
and then click
driver.findElement(By.xpath("//span[text()='Image']")).click();

Perfect. It is working fine. Thanks Ankit !

your welcome

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service