Your ultimate guide

Automation_Browser commands 2

Automation_Browser commands 2


 
getText(): To get the visible text of the located web element.
    
Example: 
WebElement text = driver.findElement(By.name("link"));
System.out.println(text.getText());



getAttribute(): To get the located web element attribute value.
Syntax: webElement.getAttribute("Attribute");

Example:
String element = driver.findElement(By.id("001"));
String elementAtrValue = element.getAttribute("name");
System.out.println(elementAtrValue);



getCssValue():
    We can use this method to get the style details of located elements.


Example
String element = driver.findElement(By.id("002"));
System.out.println(element.getCssValue("color"));





Actions:
click(): This method is used to click on the Located Web Element.

Example: driver.findElement(By.xpath("//*[@id="q"]")).click();



sendKeys(): This method is used to Fill/input the data into the text box on the web page.

Example: driver.findElement(By.xpath("//input[@name="q"]")).sendKeys("Testing Colleges");



clear(): This method is used to clear the existing data from the text box.

Example: driver.findElement(By.name("q")).clear();

- Next Page: Locators

No comments:

Post a Comment