Skip to content

Instantly share code, notes, and snippets.

@mlconnor
Last active June 18, 2018 13:47
Show Gist options
  • Save mlconnor/3933381 to your computer and use it in GitHub Desktop.
Save mlconnor/3933381 to your computer and use it in GitHub Desktop.
Get all links with Selenium in PHP
@r8928
Copy link

r8928 commented Jun 18, 2018

how about this?

if (count($driver->findElements(WebDriverBy::xpath("//a[@href]"))) != 0){
    $links = $driver->findElements(WebDriverBy::xpath('//a[@href]'));
    foreach ($links as $key => $value) {
        echo $value->getAttribute('href') . "\n";
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment