I'm following this online resource, for building an Instagram bot. In it, the instructor uses selenium, which I installed by running: pip3 install selenium
Then he mentioned using ChromeDriver. I downloaded it and installed it following this resource. I tested it and seemingly it worked, however when I tried to use it in my script it crashed, an error message occured: Error sending sync broker message: the pipe is being closed (0xE8)
The script which I ran when the error occurred is:
from selenium import webdriver
class InstaBot:
def __init__(self):
self.driver = webdriver.Chrome()
self.driver.get('https://instagram.com')
InstaBot()
How my I resolve this error? I read through dozens of articles, but still not found what causes. Help is appreciated.
I have checked your code and it works fine for me.
Try to update your chrome browser to the latest version (79.0.3945.130) and download its match ChromeDriver version (79.0.3945.36).
Note that the ChromeDriver should be on the same folder with your code.
Related
I am trying to run selenium by running the below two lines of code after giving the path to chromedriver..
from selenium import webdriver
driver=webdriver.Chrome("C:/Users/Admin/Desktop/chromedriver")
But its not working and displaying the below error.
selenium.common.exceptions.WebDriverException: Message: Service C:/Users/Admin/Desktop/chromedriver unexpectedly exited. Status code was: 1
Can you please tell how to fix it ?
Check your chrome brower version and download chromedriver accordingly from below url https://sites.google.com/a/chromium.org/chromedriver/downloads
from selenium import webdriver
browser = webdriver.Chrome(executable_path=r" path of chromedriver.exe")
browser.get('your url')
i think you are missing some libraries, i had a similar problem when i was trying stuff with selenium. try installing the chromium driver as well cause it might have the libraries you need, even if you don't want to use chromium
I've a strange problem with Python (or maybe I'm only a noob).
I wrote a little bot to automate some action on the browser using selenium and I want to run on a Ubuntu VPS, so I've installed Selenium and the other modules I needed and I ran the script but when it comes to the first of this lines
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "free_play_captcha_types")))
driver.find_element_by_id("free_play_captcha_types").click()
driver.find_element_by_id("free_play_captcha_types").click()
driver.find_element_by_xpath("//option[contains(#value, 'recaptcha_v1')]").click()
I get the socket.error: errno [111] Connection refused error.
I've already tried to run the selenium server before running the script but nothing changes... has someone have an advice?
Thank you in advance.
Another information: I ran the same script on a different VPS and it ran successfully...
It seems that a lof of people are having trouble getting Selenium to find chromedriver, so this may apply to them aswell if they actually have the chromedriver.exe in the correct path.
It seems I have everything I need to have these selenium tests working, and when I manually try running the following 2 lines, everything works fine (it finds chromedriver and opens Chrome).
from selenium import webdriver
webdriver.Chrome()
However, when I put the exact same code into a Django test and try running the test through Django, I get a "ChromeDriver executable needs to be available in the path" error. I've tried re-installing Django and Selenium to no success.
Any help would be appreciated!
The problem was actually caused by enabling Celery tasks.
I'm trying to use selenium from python but I'm having a problem running it on a RHEL5.5 server. I don't seem to be able to really start firefox.
from selenium import webdriver
b = webdriver.Firefox()
On my laptop with ubuntu this works fine and it starts a brings up a firefox window. When I log in to the server with ssh I can run firefox from the command line and get it displayed on my laptop. It is clearly firefox from the server since it has the RHEL5.5 home page.
When I run the python script above on the server it (or run it in ipython) the script hangs at webdriver.Firefox()
I have also tried
from selenium import webdriver
fb = webdriver.FirefoxProfile()
fb.native_events_enabled=True
b=webdriver.Firefox(fb)
Which also hangs on the final line there.
I'm using python2.7 installed in /opt/python2.7. In installed selenium with /opt/python2.7/pip-2.7.
I can see the firefox process on the server with top and it is using a lot of CPU. I can also see from /proc/#/environ that the DISPLAY is set to localhost:10.0 which seems right.
How can I get a browser started with selenium on RHEL5.5? How can I figure out why Firefox is not starting?
It looks like the problem I'm encountering is this selenium bug:
http://code.google.com/p/selenium/issues/detail?id=2852
I used the fix described in comment #9 http://code.google.com/p/selenium/issues/detail?id=2852#c9
That worked for me.
I am trying to lauch a Selenium scrit from a Python script and it gets stuck at "11:16:32.144 INFO - Launching Firefox..."
The Selenium server is running well, I also tried the Selenium IDE and it works. I am using Ubuntu lynx, Firefox 3.6.23, Selenium server 2.11.0
What do you think it could be ?
Thank you very much.
Regards.
It could be that Selenium can't find firefox somehow?
Is the process ending? or just hanging?
Try starting selenium runner manually, say from ipython, something like:
from selenium import selenium
sr = selenium(host, port, "*firefox*", url)
sr.start()
and see if you get an exception?