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
Related
I am trying to open a webpage using Python, and my editor is VS Code.
This is the code:
import webbrowser
webbrowser.open('google.com')
This won't work while using VS Code, but it does work when I'm using IDLE.
What am I misunderstanding? What have I not done/done incorrectly? I have the Open in Browser extension by TechER, but even with this, I can't open a web browser page while using VS Code, and nothing I've found has been remotely helpful or even hints at what to do.
I'm clearly missing something in VS Code, but I don't have even the slightest clue as to what.
Can you check which interpreter is VSCode using because sometimes VSCode downloads the interpreter somewhere else. To change the environment of VSCode you can take a look at https://code.visualstudio.com/docs/python/environments
Just Set Your Browser:
import webbrowser
firefoxPath = "C:/Program Files/Mozilla Firefox/firefox.exe %s"
webbrowser.get(firefoxPath).open(firstUrl)
in VScode
I'm still a beginner with coding so maybe this question will be trivial for some of you. My apologies in advance.
For a project, i made a webcrawler using python and selenium, with an user interface made with Tkinter. I use a chromedriver to open chrome for the webcrawling part.
I converted my Tkinter file with pyinstaller into an executable file. When doing so, i typed the following flags: --onefile -w
I was told that the latter one prevents opening a command prompt when running the file, however, when i run the executable, my pc opens the command prompt for the chromedriver. How can i fix this?
-w will prevent the creation of a console for the main exe, not for the execution of the chromedriver.
You should have a look at ChromeDriver console application hide thread for removing the console created by chromedriver
I am new in automation. Currently, I am using katalon recorder to record my web application, Then I want to export it to python2 (webdriver+unittest) to run in my machine...after I run the test script using python, it shows me some errors that unable to locate the element… But when I run in katalon recorder, everything just fine.
May I know what steps did I miss or what should I install or import in order to run the python test script same with the katalon recorder. Is there any library that katalon using to run the testscript?
Thank you.
As discussed here, automatically generated element locators tend to be pretty flaky, so the best course of action is to learn to use XPath (or other selector strategies) to pinpoint the element yourself.
Context:
I am trying to move from PyCharm to VSCode + Python extension.
The autocompletion on VSCode does not as well as on PyCharm.
As I am new with VSCode, I am not sure if it is a configuration issue on my side, or a bug on VSCode Python extension side.
E.g., when using selenium, with the following code snippet:
from selenium import webdriver
browser = webdriver.Chrome()
elem = browser.find_element_by_id('toto')
elem.
PyCharm is able to give me the following suggestions:
But VSCode does not suggest anything:
Can you guys reproduce the issue on your side?
Is this something I can fix on my side? how?
If not, then I'll file an issue.
I recently tried to convert one of my python scripts (used for file-systems I/O) to a executable file by using py2exe. However, after successfully generating the .exe file from my python script, I am no longer able to copy and paste any text(or anything for that matter) from other windows apps to my python app console (when I run the script/app from the .exe file). When right click the mouse now, the access window does not pop up any longer. Does anyone know how I can get around this issue?
Thanks,
A.L.
Right-clicking a console window is a "special feature" of the command line interpreter of Windows Vista and above. It doesn't work on any other command-line tool, so it doesn't longer works for your converted script. You can still access it using the windows menu (small icon in the title bar or Alt+Space).
You could try to get the right-click feature back by messing around with Windows API calls - but the more convenient possibility would be to enable pasting using Ctrl+V and forget about the window menu. A good candidate is PyReadline - install the package and run this at the beginning of your script:
import readline
readline.parse_and_bind("control-v: paste")