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") ๐
Clearing the search box:
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")โ๏ธ
What operations can you perform on links using Selenium WebDriver?
Me: Selenium provides a few useful APIs for interacting with links (i.e. <a> elements):
To click a link:
click()
Syntax:
driver.findElement([By.id](<http://by.id/>)("someLink")).click()
This will simulate a click on the link. ๐
To check if a link is enabled:
isEnabled()
Syntax:
driver.findElement([By.id](<http://by.id/>)("link")).isEnabled()
This returns true/false if the link can be clicked. ๐ข
To check if a link is visible:
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() ๐
Checking a disabled link:
isEnabled = driver.findElement(By.partialLinkText("Disabled")).isEnabled()
print(isEnabled) โ