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
Thanks in advance guys, any help is very welcome.
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