โ”Interview Questions

Can you list some of the webpage operations available in Selenium?

Me: Sure! Some of the main operations are:

โ™ป๏ธ Navigate to URLs:

driver.get("url") ๐Ÿ–ฅ
driver.navigate().to("url") ๐ŸŽ๏ธ

๐Ÿ‘€ Inspect the webpage:

driver.getTitle() ๐Ÿ“ƒ
driver.getPageSource() ๐Ÿ‘
driver.getCurrentUrl() ๐ŸŒ

โœ๏ธ Interact with elements:

driver.find_element_by_id().send_keys("text") ๐Ÿ”
driver.find_elements_by_class_name().click() ๐Ÿ–ฑ

๐Ÿ“ท Take screenshots:

driver.get_screenshot_as_file("filename.png") ๐Ÿ“ธ

โŒจ๏ธ Send keyboard inputs:

Actions().send_keys().perform() ๐Ÿ’ป

๐Ÿ–ฑ Perform mouse actions:

Actions().move_to_element().click().perform() ๐Ÿ–ฑ

What WebEdit operations are available in Selenium?

Me: WebEdit refers to text fields, input boxes, and text areas on a webpage. Selenium provides these useful APIs to interact with WebEdits:

To enter text in a text field:

sendKeys()

Syntax:

driver.findElement([By.id](<http://by.id/>)("textbox")).sendKeys("TestData")

This will type the string "TestData" into the text field. ๐Ÿ”ค

To clear text from a text field:

clear()

Syntax:

driver.findElement([By.id](<http://by.id/>)("textbox")).clear()

This will empty any existing text from the field.โœ‚๏ธ

Entering a search query:

driver.findElement([By.name](<http://by.name/>)("q")).sendKeys("selenium testing") ๐Ÿ”
driver.findElement([By.name](<http://by.name/>)("q")).clear() โœ‚๏ธ

Filling out a form:

driver.findElement(By.className("fname")).sendKeys("John")
driver.findElement(By.className("lname")).sendKeys("Doe")โœ๏ธ

Me: Selenium provides a few useful APIs for interacting with links (i.e. <a> elements):

click()

Syntax:

driver.findElement([By.id](<http://by.id/>)("someLink")).click()

This will simulate a click on the link. ๐Ÿ‘ˆ

isEnabled()

Syntax:

driver.findElement([By.id](<http://by.id/>)("link")).isEnabled()

This returns true/false if the link can be clicked. ๐ŸŸข

isDisplayed()

Syntax:

driver.findElement([By.id](<http://by.id/>)("link")).isDisplayed()

This returns true/false if the link is visible on the page. ๐Ÿ‘๏ธ

driver.findElement(By.linkText("Terms")).click() ๐Ÿ“„
isEnabled = driver.findElement(By.partialLinkText("Disabled")).isEnabled()
print(isEnabled)  โŒ

Last updated

Was this helpful?