how To Click on Link in Selenium Webdriver

How to Click on link in Selenium webdriver ?
There are two way to click on link in selenium.
1)LinkText() 
2)Partial LinkText()

Selenium Code to Click on Link Using Java


linkText ()

Here We Have write the Code for Click on Facbook forgot account Link using Link Text 


package firstpackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class LinkText
 {
 public static void main(String[] args
{
System.setProperty("webdriver.chrome.driver", "C:\\Software\\Chrome Driver\\chromedriver_win32 (1)\\chromedriver.exe");

WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com");
driver.findElement(By.linkText("Forgotten account?")).click();
 }
}

 paritalLinkText ()

Here We Have write the Code for Click on Facbook forgot account Link using partial link text 

package firstpackage;
 import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class LinkText
 {
 public static void main(String[] args)
 {
System.setProperty("webdriver.chrome.driver", "C:\\Software\\Chrome Driver\\chromedriver_win32 (1)\\chromedriver.exe");

 WebDriver driver=new ChromeDriver();
  driver.manage().window().maximize();
  driver.get("https://www.facebook.com");
  driver.findElement(By.partialLinkText("en account?")).click();
}
}

Hope !! The above Code How to Click on link in Selenium Helpful for You ....
Team 
QA acharya
 
Tags: How to click on link in selenium browser , Link Text method in selenium , Partial link text in selenium webdriver , clicking on link in selenium webdriver using java

How to Click on Link in Selenium 





Post a Comment

0 Comments