Troubleshooting of selenium errors

From LemonWiki共筆
Revision as of 21:41, 27 October 2020 by Planetoid (talk | contribs)
Jump to navigation Jump to search

SeleniumHQ Browser Automation (php-webdriver/php-webdriver: PHP client for Selenium/WebDriver protocol. Previously facebook/php-webdriver)

How to tracking the selenium errors

  • Checking the standalone selenium server is running or not ps aux | grep selenium on Linux Os linux.png
  • Checking the log file of standalone selenium server e.g. launching the server by the command sudo nohup java -jar selenium-server-standalone-3.141.59.jar > /home/user/selenium.log 2>&1 &. The log file was located at /home/user/selenium.log
  • Checking the error log file of HTTP server e.g. sudo tail /var/log/nginx/error.log

How to resolve Uncaught Facebook\WebDriver\Exception\InvalidSelectorException

Error message

PHP Fatal error:  Uncaught Facebook\WebDriver\Exception\InvalidSelectorException: invalid selector: The result of the xpath expression "xxx" is: [object Attr]. It should be an element.
  (Session info: chrome=83.0.4103.61) in /path/to/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:105

Situation

  • After the term was keyed in into the text box, the script shuld auto click the specified button which specified by XPath expression.

Possibile soultions

  • Solution1: Using headless chrome[1]
  • Solution2: Not click the button which specified by XPath expression. Send the ENTER to submit the form[2].

How to resolve [WARNING]: This version of ChromeDriver only supports Chrome version xx or [WARNING]: This version of ChromeDriver has not been tested with Chrome version 86

Situation

  • Download the same version of ChromeDriver with the version installed on the computer or server
  • You may need to stop the ChromeDriver in the process list if you could not overwrite the existing ChromeDriver file
    • Win Os windows.png (1) keyin cmd to open the command prompt with the administrative permission (2) and keyin taskkill /IM "chromedriver.exe" /F to stop the ChromeDriver process
    • Linux Os linux.png
  • Overwrite the existing ChromeDriver file

References


Troubleshooting of ...

Template