I'm using chrome, and I've been trying to find a way to count open windows with python, I know it can be done with selenium but it only counts the open windows in the webdriver, is there any way to do it in "normal" chrome? What I need is the number of the total opened windows.
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
There are times that I may have dozens of tabs open at one time. How would I go about pulling all open tabs, windows, and pages into a python script?
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.
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/");
With Selenium Webdriver, I have to upload some files on a website but since the pop-up window for browsing the file location is handled by the operating system and not the browser, I cannot automate that part with Selenium.
So I want to know which framework or module I need to use to work with system windows of Windows OS. Can tkInter or wxPython be used for this?
My script will be used on Windows 7, 8 & 10.
Actually, you can upload files without interacting with upload prompt pop-ups.
To be able to handle file upload with selenium you should send path to file to appropriate input field without clicking on "Upload" button. Try following:
path_to_file = 'C:\\Files\\path\\to\\file' # use your specific path instead
driver.find_element_by_xpath('//input[#type="file"]').send_keys(path_to_file)
P.S. Let me know if this code doesn't work as you expect
You can call autoit3 framework from Python even to open the File Open dialog and fill in the values and press OK or do whatever with the windows. Autoit3 has a dll that can be loaded and called using ctypes. That's what I did in one or 2 projects.
If I understand your question correctly, wxpython or tk won't help you. They can be used to make the windowed UI, not to control other programs.