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.
Related
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
I want to open a new tab on Selenium Firefox (on Python 3.6 and MacBook) but the command key does not work to open a new tab. For example,
driver.find_element_by_tag_name('body').send_keys(Keys.DOWN)
This works (moves a page a little down). But the following code does not work.
driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + "t")
, which should open a new tab. Another key such as "q" does not work, either.
So I'm looking for a way to open a new tab (or any other command key combinations) on Selenium and Firefox.
Is there any way except the keyboard shortcut?
To open a New Blank TAB you can use the following line of code :
driver.execute_script("window.open('','_blank');")
To open a New TAB with url you can use the following line of code :
driver.execute_script("window.open('http://facebook.com/');")
Update
As per your comment update execute_script("window.open('','_blank');") should open a new TAB by default. Incase you are seeing different behavior you need to follow the below mentioned steps :
Upgrade Selenium to current levels Version 3.11.0.
Upgrade GeckoDriver to GeckoDriver v0.20.1 level.
Upgrade Firefox version to Firefox v59.0.1 levels.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
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.
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.
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/");