Search On Google

Tuesday, February 19, 2019

LinkText vs partialLinkText method

What is linkText?
Link text are text display for  a link . You can say a understandable form of link which can be user friendly.

What is partial link text?
Partial means some part of main link. You can under stand when you see example below.

<a href="www.google.com">Click here to download</a>

Link text example:- Click here to download
Partial linked text:-
 Click
Click here
here to
download
here to download
load
down

By example you can see partial link may be much more but linkText will be only one.

Java code example:-
By.linkText("click here")
By.partialLinkText("here")


JAVA code complete example you can execute this:-

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

public class LinkAndPartialLinkTextExample {   
     
    public static void main(String[] args) {       
        String baseUrl = ""www.onlinetutorial.info"";   
        System.setProperty(""webdriver.chrome.driver"",""C:\\chromedriver.exe"");   
        WebDriver driver = new ChromeDriver();   
         
        driver.get(baseUrl);   
        driver.findElement(By.partialLinkText(""down"")).click();
        //driver.findElement(By.linkText(""click here to download"")).click();   
       
        driver.quit(); 
    } 
}

No comments:

Post a Comment

About Me

My photo
Mumbai, Maharashtra, India