Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to access Links and tables in selenium web driver

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 553
    Comment on it

    Dear User,

    In the last blogs I had explained about Regular expressions, now In this blog, I will explain you about how we can access links and tables using selenium web driver.

    We can access links an exact match or partial according to test scenarios in automated code through selenium web driver.


    Exact match:

    We can access links with exact match or we can locate elements of the link through by.linkText () method. We can find elements using Inspect elements and get exact link in HTML code as below

    <a href = ""> Hello </a>

    and we save this in HTML format in any drive and after click 'Hello' link text , this will navigate you page.

    For running this we write web driver code as below and access 'Hello' link text and open page.


    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    public class misbah {
       public static void main(String[] args){
              String baseUrl ="file:///C:/Users/misbah/Desktop/misbah.html";
              WebDriver driver;
              System.setProperty("webdriver.gecko.driver", "D:\\Selenium\\Eclipse New setup(Neon)\\geckodriver.exe");
              driver= new FirefoxDriver();
               String s=driver.getTitle();

    In the above code first we make one object of firefox browser as a driver, using this object we get a baseurl of HTML which is saved in Desktop , If we run above code in eclipse then open in firefox browser and we get the Output as Title: linkedin.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: