0% found this document useful (0 votes)
17 views7 pages

Selenium Commands Interview Questions

The document provides answers to common Selenium WebDriver questions, including how to retrieve text from a textbox, get link text, extract all values from a dropdown, and select a radio button option. It includes code snippets for each task, demonstrating the use of methods like getAttribute, getText, and getOptions. The document serves as a quick reference for Selenium users looking to perform these actions in their automation scripts.

Uploaded by

gowtham tadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

Selenium Commands Interview Questions

The document provides answers to common Selenium WebDriver questions, including how to retrieve text from a textbox, get link text, extract all values from a dropdown, and select a radio button option. It includes code snippets for each task, demonstrating the use of methods like getAttribute, getText, and getOptions. The document serves as a quick reference for Selenium users looking to perform these actions in their automation scripts.

Uploaded by

gowtham tadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. How to get the entered text from the textbox.?

Ans: driver.findElement(By.name(“q”)).getAttribute(“Value)

2. How to get link text.?

Ans: driver.findElement(By.ClassName(bt_p)).getText(0;

3. How to get all values in dropdown.?

Ans: to get all items from the dropdown

Select drpitems = new Select( driver.findElement(By.name(“country”)));

List<WebElement> items = drpitems.getOptions();

Int size = items.size();

System.out.println(“Total number of items ” =size);

For (int i=0; i<size;i++)

Int j =i+1;

System.out.println(“Item “+j+” Dropdown value is ”+items.get(i) .getText());

4.How to get Radio Group & Select one option?

Ans:

List<WebElement> radios = driver.findElements(By.name(“ServClass”));

System.out.println(“Display the radio size”+ radios.size());

Radios.get(2).click();

You might also like