I have been struggling to figure out why I keep getting errors trying to use selenium. I'm using a local install of anaconda3 on my /home/user unix drive at the company I work for. I already pip installed selenium, seemingly without issue, but when I try the following:
from selenium import webdriver
driver = webdriver.Firefox()
it fails with the following message:
WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
I've tried downloading the most current chromedriver and trying with that, I've tried installing another gecko-driver, I've tried all kinds of things. But nothing is working. I'm happy to provide any amount of additional information, I just want to get this off the ground at some point...
Thank you!
from selenium import webdriver
path = r'C:\yourgeckodriverpath\geckodriver.exe'
driver = webdriver.Firefox(executable_path=path)
Alright, through a combination of the responses to this question, I have figured out what (I think) went wrong. I was using a linux anaconda install on my company's servers, which (I believe) meant my python had no access to a browser driver. The solution was sadly to install anaconda locally, manually download/unzip/install selenium and geckodriver, and then make sure I pass the whole "executable_path=path" parameter to the Firefox method. This didn't work for Chrome for some reason, which I'll assume has something to do with the unchangeable security specifications on my work machine. If any part of this doesn't sound right, feel free to chime in and shed more light on the issue. Thanks!
Related
I got an WebDriverException error, saying that chromedriver.exe needs to be in path, but as you see in the second picture, I have already done that. I am also having trouble figuring out the "unknown error: DevToolsActivePort file doesn't exist"). Attached is the error. Right now I am using this website (https://christophegaron.com/scraping-linkedin-posts-with-selenium-and-beautiful-soup/) to download Chrome Driver and Selenium to my laptop (I already have BeautifulSoup on my laptop so I don't need that one). Also, I have both Ubuntu and Linux, so I am open to using either to solve my issue. I am also using Python 3.8.5, Ubuntu 20.04.2, Chrome version 91, and Linux version 4.4.0.
Also if anyone has any tips regarding how to scrape LinkedIn posts that would be amazing!
picture of the errors/exceptions
picture of code
Thanks for your help! I found that my error was that I was using Ubuntu on a Linux machine (as a VM), when I should have just ran the Chromium program on a natural machine.
I am trying to run a simple script to open up a google page on Chromium Edge using Python.
What I have so far is
Import selenium
From selenium import webdriver
Path= “..../msedgedriver.exe”
Driver= webdriver.Edge(executable_path=path)
Driver.get(https://google.com)
Got below error:SessionNotCreatedEcception:session not created from tab crashed(Session info:MicrosoftEdge=91.0.864.41)
Tried several things and searched online but no luck yet.Any help will be much appreciated!
There are some problems in the code you provide, I fixed them and tested it, and it works well. My Edge Version is 91.0.864.41 (Official build) (64-bit).
Below is my sample code and you can also try:
import selenium
from selenium import webdriver
path= "D:\\webdriver\\msedgedriver.exe"
driver= webdriver.Edge(executable_path=path)
driver.get("https://www.google.com/")
Please note to modify the path to you owns and use the absolute path of the WebDriver.
I think it may just be a code problem that causes the error.
If the problem persists, can you please provide more information? Such as what version of selenium are you using and what operating system are you using?
I'm using Selenium with Python (3.5) to programmatically explore a site. One step of this exploration includes scrolling to the bottom of a given page, and I have chosen to do so with jQuery as such where driver is the webdriver object and scrollloadtime is the set amount of time I want the scrolling to take:
driver.execute_script("$('html, body').animate({scrollTop: $(document).height() - $(window).height()}, %s);" % scrollloadtime)
This is where things get weird. When I run this code in a test environment (VM running Kali Linux), I have no issues with this -- I've never once had a problem with this line running in this environment.
However, when I attempt to run the exact same code with the exact same package versions (which I have listed below) on the exact same webpage inside a docker container running Debian Stretch, I get the following error:
Message: TypeError: $(...).animate is not a function
I'd like to figure out why this is happening rather than just a workaround. It's driving me insane!
I'm certainly no jQuery expert, but from the research I've done on the above error this normally occurs when either an old and minimized jQuery version is being used. What I can't figure out myself is how that solution then ties into Selenium or even Python itself.
Things I have tried, to no avail:
Installed jquery-related packages that exist on my test environment that did not exist within the docker image, on the docker image (i.e. all libjs-jquery* packages).
Attempted to inject jQuery into the page before running the script which triggers DDoS security. (Additionally, this shouldn't be necessary because the jQuery script worked without any injection in the test environment)
Attempted to exchange the initial $('html, body') with a defined variable (var x = document.getElementsByTagName('html')[0]; x.animate(...), though I will be the first to admit that I might not have done so correctly
Versions:
Python 3.5
Selenium (Python) 3.141.0
Geckodriver 0.24.0
Firefox ESR 68.1.0
Debian Stretch and Kali Linux
Any assistance or troubleshooting guidance would be greatly appreciated. Let me know if I can provide any additional information.
I want to crawl some images for my machine learning practice and found this google-image-download to very useful and the codes works out of the box.
However, at the moment, it only allow not more than 100 images, which is the limit from google image page(that only load 100 images per page).
The document said if you are using pip install google_images_download(which in my case, I am doing that), it will download together with selenium and by using chromedriver, you can download more than that limit.
however, everytime I run the code python gimages.py:
from google_images_download import google_images_download
response = google_images_download.googleimagesdownload()
arguments = {"keywords":"number plates","limit":200,"print_urls":True}
paths = response.download(arguments)
print(paths)
I will get error:
Looks like we cannot locate the path the 'chromedriver' (use the
'--chromedriver' argument to specify the path to the executable.) or
google chrome browser is not installed on your machine (exception:
expected str, bytes or os.PathLike object, not NoneType)
as I checked my installation, selenium already installed:
reading further, it said I can download chromedriver and put inside the same folder and call python gimages.py --chromedriver "chromedriver", I still get the same error.
How can I resolve this?
I am using conda with python 3.6, running the terminal from conda. the code is already working, just that chromedriver part is not.
You need to specify the path... "chromedriver" is not a path...
You might need to the explicit path "/path/to/chromedriver/folder".
In your case: python gimages.py --chromedriver "/path/to/chromedriver/folder"
Hope this helps you!
I keep getting errors like this when running my script (it uses chromedriver):
[15796:2516:0519/121100.926:ERROR:platform_sensor_reader_win.cc(242)] NOT IMPLEMENTED
Is there an easy way just to ignore these errors because as far as I can tell they're not causing anything but it spams the log up a bit?
It actually isnt an issue with chromedriver but rather with chrome v63 or higher. Chrome v63 has bugs in its ShaderCache which is causing this. The easiest fix is downgrading to chrome v60-61 and using chromedriver v2.33 Worked for me. this is the 'Google Chrome Older Versions' :https://www.slimjet.com/chrome/google-chrome-old-version.php
,and this is the chrom driver Mirror:http://npm.taobao.org/mirrors/chromedriver/
Hope that resolves your problem