Error While Running Program To Extract All Links Present | Selenium Forum
M
Posted on 06/01/2016
Hi Ashish,

I am getting error While running program to extract all links present on BBC webpage as you explained in video part 3 of Module 13.Could You Please tell me why I am getting this error and what is the solution for this? And one more doubt in this Will this program extract the Link(s) who have tag name "span" from this program as you explained(I wrote the same.)? Because I have written here from "List<WebElement>allLinks= driver.findElements(By.tagName("a"))". Please refer attached screenshots for your reference.Thanks in advance.

M
Replied on 06/01/2016

Since WebDriver tries to simulate real users, it cannot interact with elements which are invisible/hidden.

There can be so many reason for this. solve this using different ways.

1- Using WebdriverWait that is also know as explicit wait

2- Using unique xpath- using xpath ways.

3- Get the size of element then click or perform any action on first one.


M
Replied on 09/01/2016

And one more doubt in this Will this program extract the Link(s) who have tag name "span" as you explained(I wrote the same.)? Because I have written here from "List<WebElement>allLinks= driver.findElements(By.tagName("a"))". I am a bit confused that here I have written code for links who have tag name "a" but I am expecting it will extract the link(s) who have tag name "span" also.Will it work?


M
Replied on 09/01/2016

if you want to extract span use tagname("span");

tagname("a"); will extract all hyperlink and nothing else(so no span tags).