Editing
Troubleshooting of selenium errors
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
[https://www.selenium.dev/ SeleniumHQ Browser Automation] ([https://github.com/php-webdriver/php-webdriver php-webdriver/php-webdriver: PHP client for Selenium/WebDriver protocol. Previously facebook/php-webdriver]) == How to resolve the selenium errors == * Checking the standalone selenium server is running or not {{kbd | key=<nowiki>ps aux | grep selenium</nowiki>}} on {{Linux}} * Checking the log file of standalone selenium server e.g. launching the server by the command {{kbd | key=<nowiki>sudo nohup java -jar selenium-server-standalone-3.141.59.jar > /home/user/selenium.log 2>&1 &</nowiki>}}. The log file was located at {{kbd | key=<nowiki>/home/user/selenium.log</nowiki>}} * (optional) Checking the port where the selenium server is running e.g. {{kbd | key=<nowiki>wget http://localhost:4444</nowiki>}} * Checking the error log file of HTTP server e.g. {{kbd | key=<nowiki>sudo tail /var/log/nginx/error.log</nowiki>}} * (optional) Checking the error log file of PHP-FPM e.g. {{kbd | key=<nowiki>sudo tail /var/log/www.access.log</nowiki>}} which its file path defined in the configuration file {{kbd | key=<nowiki>/etc/php-fpm.d/www.conf</nowiki>}} * (optional) Checking the keyboard event e.g. CTRL works on {{Win}} but not works on {{Mac}}<ref>[https://stackoverflow.com/questions/30937153/selenium-send-keys-what-element-should-i-use python - Selenium - send keys - what element should I use - Stack Overflow]</ref> == How to resolve Uncaught Facebook\WebDriver\Exception\InvalidSelectorException == Error message <pre> 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 </pre> Situation * After the term was keyed in into the text box, the script shuld auto click the specified button which specified by [https://www.w3schools.com/xml/xpath_syntax.asp XPath expression]. Possibile soultions * Solution1: Using headless chrome<ref>[https://developers.google.com/web/updates/2017/04/headless-chrome Getting Started with Headless Chrome | Web | Google Developers]</ref> * Solution2: Not click the button which specified by XPath expression. Send the {{kbd | key=ENTER}} to submit the form<ref>[https://stackoverflow.com/questions/21243860/emulate-keypress-in-webdriver-using-php selenium - Emulate keypress in webdriver using php - Stack Overflow]</ref>. == 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: Updating the ChromeDriver * Before Updating, If you encounter “file in use” errors: ** {{Win}} Open Command Prompt as Administrator, Run command: {{kbd | key=<nowiki>taskkill /IM "chromedriver.exe" /F</nowiki>}} * Two option to update the ChromeDriver ** Option 1: Manual Download: Download ChromeDriver from [https://chromedriver.chromium.org/downloads ChromeDriver Downloads] ** Option 2: Package Managers: On {{Mac}}/{{Linux}}, use [https://brew.sh/ Homebrew]. On {{Win}}, use [https://chocolatey.org/ Chocolatey]. * Ensure the version matches your installed Chrome browser. Replace the existing ChromeDriver file == How to resolve macOS says the *.app is damaged. What now? == Error message<ref>GoogleChromeLabs/chrome-for-testing https://github.com/GoogleChromeLabs/chrome-for-testing</ref><ref>[https://errerrors.blogspot.com/2023/07/how-to-fix-google-chrome-for-testing.app-is-damaged-and-cannot-be-opened.html 解決「Google Chrome for Testing.app」已損毀,無法打開。 你應該將其丟到「垃圾桶」的問題]</ref> <pre> “Google Chrome for Testing.app” is damaged and can’t be opened. You should move it to the Trash. </pre> Solution * Open the terminal, and key-in the following command: <pre> xattr -cr 'Google Chrome for Testing.app' </pre> == References == <references /> {{Template:Troubleshooting}} [[Category:Web scraping]]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Kbd
(
edit
)
Template:Linux
(
edit
)
Template:Mac
(
edit
)
Template:Troubleshooting
(
edit
)
Template:Win
(
edit
)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information