1

Good afternoon,

I am trying to open several links within a foreach using Facebook WebDriver, but it only opens the first one.

The links are arriving correctly, string, but on the second link it hangs and displays the error below.

It seems to me that selenium drive has a cookie or cache problem.

foreach($subjectsList as $subject) { // Get all info subjects each course. $subjectTitle = $subject->getText(); $subjectLink = trim($subject->getAttribute('href')); $rawPage = $this->seleniumDriver->get($subjectLink); } // end Foreach for subjectsLis 

enter image description here

Thanks in advance guys, any help is very welcome.

0

1 Answer 1

1

It's not a cookie or a cache problem, it's conceptual.

$rawPage = $this->seleniumDriver->get($subjectLink); performs browser navigation. So, your code will correctly parse out the first link, and navigate to it. But, when it tries the second link, selenium correctly identifies that $subject is essentially a dangling pointer (well, it contains a C pointer which is technically the dangling pointer, but...) to a DOM element in the previous (deallocated) webpage/dom-tree.

To do what you're looking for, first parse out the titles/hrefs to strings, then iterate over the strings.

I'd take a look at the relevant documentation

Sign up to request clarification or add additional context in comments.

4 Comments

to de honest i can't undesterdant everything u told me. But, when u told me for to do title/href as a string, it's already did, when i tried to use .get(), i use string
The point is to extract all relevant info from $subjectsList before calling get(). Using the get() method causes the browser to load a new page from a url, replacing the currently loaded page (read the docs). Once that happens, the elements in $subjectsList are now part of a page that no longer exists.
Thanks for reply me. I did what u told me, but still dosen't work :( It's not possible insert a new img here, so i did it on this link: share.getcloudapp.com/eDu9ry8z So i tried to do it a different way, now i got all the links in array then i iterate over it, but still not work when the line 735 it called.
i thinking i added u on my facebook, if not and ig u can help me, add me: facebook.com/gfilgueiras

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.