--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/sblDMxldjN8J.
For more options, visit https://groups.google.com/groups/opt_out.
package Practice_pack_1;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class CheckTextisLinkNameorNot {
WebDriver driver;
@BeforeTest
public void open()
{
driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.google.com/");
}
@AfterTest
public void close()
{
driver.quit();
}
@Test
public void textcompare()
{
List<WebElement> elements=driver.findElements(By.tagName("a"));
int totallinks=elements.size();
for(int i=0; i< totallinks; i++)
{
String element= elements.get(i).getText();
String av="News";
if(av.equals(element))
{
System.out.println("News is link text");
}
else
{
//System.out.println("News is not a link text");
}
}
}
}