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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 751
    Comment on it

    Dear user,

    In the last blog, I had explained, how we can access link using exact match, and now in this blog, I will guide you about how to access link using partial match in selenium web driver.


    Partial Match:

    We access links using a portion of their link text or we can say that partial match or we can locate elements of the link through by.partialLinkText () method. We can find elements using Inspect elements and get exact link in HTML code as below


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

    and we save this in HTML format with the name of misbah.html in any drive and after click 'Partial Hello' link text , this will navigate you page.

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

    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 base URL 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: