Day - 5 - WebElement Methods
Day - 5 - WebElement Methods
Methods of webElement
A).sendKeys():
Syntax:
driver.findElement.sendKeys(“”);
WebSite:- https://demowebshop.tricentis.com/register
driver.findElement(By.name("FirstName")).sendKeys("pooja");
B).click():
Syntax:
driver.findElement.click();
WebSite:- https://demowebshop.tricentis.com/register
driver.findElement(By.id("gender-female")).click();
C).getText():
getText() method it is used to find text value of element return type of this
method is string.
Syntax:
String s1 = driver.findElement.getText();
WebSite:- https://demowebshop.tricentis.com/register
D).getAttribute():
getAttribute() this method will get the value from textbox, return type of this
method is String.
Syntax:
String s1 = driver.findElement.getAttribute();
WebSite:- https://demowebshop.tricentis.com/register
String at =
driver.findElement(By.xpath("//*[@id=\"LastName\"]")).getAttribute("id");
E).clear():
Syntax:
driver.findElement.clear();
WebSite:- index.html
driver.findElement(By.xpath("//input[@id='uid']")).clear();
F).submit():
submit() method it is just similar like click method.It is used to submit page
value.
Syntax:
driver.findElement.submit();
WebSite:- index.html
driver.findElement(By.xpath("//button[@id='login']")).submit();
G).isDisplay():
isDisplay() method will check whether the element display or not, return type is
boolean.
Syntax:
boolean br=driver.findElement.isDisplay();
WebSite:- https://demowebshop.tricentis.com/register
Syntax:
WebSite:- https://demowebshop.tricentis.com/register
boolean br =driver.findElement(By.id("gender-female")).isSelected();
I).isEnabled():
Syntax:
WebSite:- https://demowebshop.tricentis.com/register
Boolean check =
driver.findElement(By.xpath("//button[@id='login']")).isEnabled();