Selenium or Chromedriver randomly stopped working with Python - python

I have a few scripts in Python that use selenium and chromedriver for web scraping. They have worked fine for months but as of last night (04/06/2017) they started giving errors when I try to do anything with chromedriver. For example, these two lines of code produce a not secure error inside the browser address bar.
browser = webdriver.Chrome()
browser.set_window_position(-10000, 0)
My scripts were made using Python 3.5. I installed Python 3.6 but I am still using idle from 3.5. I installed Python 3.6 about 2 weeks ago and didn't have any problems with my scripts working. Why did this randomly start happening, which one of the two is the problem, and how can I fix this?

After downloading the newest version of chromedriver.exe and replacing the old chromedriver my issue was resolved. I still get a not secure error on the browser when it opens but my scripts continue to run now.

Related

Using Firefox 50 in Selenium Python

I am making a program with Selenium Python, which is an automation program.
The problem I have is that I must use Firefox version 50 and when I try to open the browser, it gives me an error and does not open the link.
I had a few questions, the first is that
Is there another package for automation in Python?
Is there a solution so that I can use Firefox version 50 in the program to work?
I want to open Firefox version 50 with Selenium Python

Different selenium behaviour on Python

Dear Python community,
I did a small scrip on Python 3 with Selenium to automatize some basic tasks online. It worked fine. It opened the firefox browser, logged in on a web, type text on a search field, etc. Nothing too fancy.
I am still learning and trying different things so in the meantime I installed anaconda, python 2.7, and updated python 3 form 3.4 (I think) to 3.6. I messed something up with all this.
Now my script doesn't work anymore...
First it complaint that the geckodriver was not found. I am sure I didn't installed the first time. Anyway I downloaded it and put it on a Path enviroment varible.
Script then runs but doesn't stop were it did before. It does not wait for the page to load. If I don't want it to fail I have to use the explicit/implicit wait on selenium.
I have problems as well when finding elements on the web using browser.find_element_by_partial_link_text that when I wrote the script worked well.
def download(serial,apoc_user,apoc_pass):
shutil.rmtree(aux.download_path, ignore_errors=True)
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', aux.absolut_path + aux.download_path)
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', aux.all_types_of_files)
browser = webdriver.Firefox(firefox_profile=profile)
browser.get("https://some.web.com")
elem = browser.find_element_by_id('username')
elem.send_keys(user)
passElem = browser.find_element_by_id('password')
passElem.send_keys(password)
browser.find_element_by_id('loginBtn').click()
elem = browser.find_element_by_id('Asset')
elem.send_keys(serial)
elem.submit()
Before twinkering my code, does someone know what is going now?
I currently have python 3.6 and selenium 3.0.0. I tried with python 3.5 and selenium 3.0.2 without success.
I code with Pycharm Community Edition running on windows 7.
Any help will be welcomed!
Thank you all.

Windows: Selenium webdriver.Firefox hangs

I am new to windows and this is the first time I am running a Python program on windows.
I am running a crawler program that uses selenium and firefox webdriver.
My program runs successfully on mac/ubuntu, but on windows
webdriver.Firefox()
open a new geckodriver window(cmd like window) and just hangs there nothing after that. Program doesn't move forward after that.
Windows 7
geckodriverv0.13
Your problem is most likely the compatibility between Firefox and your GeckoDriver. Try using the latest Firefox and geckodriver. If you have a problem with Firefox, try reinstalling it and disable automatic updating.

Selenium Chromedriver launches Chrome, but doesn't open website (new Chromedriver, same old issue)

I am having trouble using Selenium Chromedriver on Windows 7. To display the problem, I've boiled it down to a simple script to simply launch the New York Times website:
from selenium import webdriver
# --LOCATIONS --
# The Chrome app:
# C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
# The Chrome binary:
# C:\Python27\Scripts\chromedriver.exe
chromedriver_path = "C:\Python27\Scripts\chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver_path)
driver.get('https://www.nytimes.com/')
The Chrome Browser launches (leading me to speculate that there's nothing with the Chrome application path), but rather than going to the NYT website, the following happens:
The string data:, appears in the URL address bar, and 2 alert notifications come up: one that says "You are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer." and another that says "Disable developer mode extensions: Extensions running in developer mode can harm your computer. If you're not a developer, you should disable these extensions running in developer mode to stay safe."
This didn't happen when I used Selenium for Firefox- so I'm not sure what to do with Chrome. I've tried looking this issue up on the internet beforehand, but all the issues/solutions are dated from a few years back (2014-2015), and I believe the Selenium packages and Chromedriver binaries have been updated since then.
Does anyone know how I can get my code working? Thank you in advance.
I'd have to see your computer to examine how Chromedriver is installed, but as that's not quite feasible, I would at least recommend uninstalling any chromedriver executables on your computer and then downloading it into your project's directory.
It's really just an IT rule-of-thumb; if you've ruled out every other issue that you're aware of, then there's a good chance the problem is something you're not recognizing. Start at square 1 and reinstall Chromedriver.
You can disable Developer mode extension by following code(java)
ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches","--disable-extensions");
System.setProperty("webdriver.chrome.driver","F:\\Stuff\\Jars\\chromedriver.exe");
driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.get("https://www.nytimes.com/");

Hide console of phantomJS driver

I'm using phantomJS driver (in python 3.3). I initialize it by
self._phantom = webdriver.PhantomJS('path/to/phantomJS.exe')
And this is OK, console doesn't appear. But when I build the project using cx_freeze to exe file, then the console does appear.
It's not much a problem, but my program opens about 3 windows and dialogs, and another windows (especially console) might be too confusing or distracting for customer.
Thank you for your advice.
I ran in the same problem and I was able to fix it by patching the selenium python module.
This is the file, I've submitted a patch to the selenium github
https://github.com/Lazik/selenium/blob/d790915a1124bd4730f10855c7e0a40ab6e6b59f/py/selenium/webdriver/common/service.py
Overwrite the service.py file you can find it in
your python_install folder\Lib\site-packages\selenium\webdriver\common
Mine is here:
C:\Python33\Lib\site-packages\selenium\webdriver\common

Categories

Resources