Discussion:
[selenium-users] Error en metodo de getlinks me podrian ayudar con el por que porfavor?
Matthew Ramirez
2018-11-29 01:37:09 UTC
Permalink
package testngpackage;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class links {
public WebDriver driver;
@BeforeTest
public void openbrowser() {


System.setProperty("webdriver.chrome.driver",
"C:\\Driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://www.facebook.com");
}
@Test
public void getlinks() {

List<WebElement> links = driver.findElements(By.tagName("a"));
System.out.println("Numero de links = " +links.size());

String[] linktext = new String[links.size()];

int i=0;
for(WebElement e:links) {
linktext[i]= e.getText();
i++;
}

System.out.println(Arrays.toString(linktext));
}

@AfterTest
public void close() {
driver.close();

}

}
--
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-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/413fc1d4-58ae-432f-b6bd-b9ef94739b1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Venu G
2018-11-29 08:37:32 UTC
Permalink
cambia tu código con el código de abajo

for(WebElement e:links) {
System.out.println(e.getText());
}



On Thursday, November 29, 2018 at 9:05:35 AM UTC+5:30, Matthew Ramirez
Post by Matthew Ramirez
package testngpackage;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class links {
public WebDriver driver;
@BeforeTest
public void openbrowser() {
System.setProperty("webdriver.chrome.driver",
"C:\\Driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://www.facebook.com");
}
@Test
public void getlinks() {
List<WebElement> links = driver.findElements(By.tagName("a"));
System.out.println("Numero de links = " +links.size());
String[] linktext = new String[links.size()];
int i=0;
for(WebElement e:links) {
linktext[i]= e.getText();
i++;
}
System.out.println(Arrays.toString(linktext));
}
@AfterTest
public void close() {
driver.close();
}
}
--
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-users+***@googlegroups.com.
To post to this group, send email to selenium-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fbfae941-aa52-4a23-8b20-cb0d0c1469dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...