How to configure auto completion? - python

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.

Related

Python Extension is not working in vscode bc of & command

I installed python then configured it for vscode by following docs of vscode, but they said I have to right-click on the editor after seeing a run Python in terminal. And I have to click on it.
But it only works in Powershell and when I tried to use it in cmd, then they said ----
D:\Program\Applications\C++>& D:/Compilers-Interpreters/Python38-32/python.exe d:/Program/Applications/C++/app.py
& was unexpected at this time.
D:\Program\Applications\C++>
I am using the C++ folder bc I was also trying to set up C++ by following the tutorial in vscode doc. Now can someone tell me how to fix this & problem????
This is a problem with VSCode, On the VSCode insiders it has been solved. You can wait for the next stable release of VSCode.
You can take this as a workaround for now:
Take adventage of terminal.integrated.shell.windows instead of terminal.integrated.defaultProfile.windows for now.
You can refer to here for more details.
It seems that for some reason & is being added to the beginning of your command, which makes the command invalid.
Upon testing, I actually am running into the same issue, suggesting it could be an issue with VS Code and Python. I would recommend using the debugger to run your program, which still seems to work. Just press F5 and select Python File: Debug the currently active Python file. Another way to do this is to define the launch.json configuration to automatically launch upon pressing F5.

Python webbrowser.open() not working in VS Code

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

selenium library is not showing up in pycharm when writing the first script

I am beginner to the pycharm selenium, i have to create the first project in selenium but when i am writing the script it is not displaying the inbuilt method whereas when i am running the script through python console it is running and opening the browser.
I have installed the selenium package but when i am running first script in selenium it is able to run and giving error also when i am writing the script it is not displaying the inbuilt method
from selenium import webdriver
driver = webdriver.chrome()
driver.get("")
driver.**
can anybody please help ...
When you create project in pycharm check selenium module and its submodules present under ..\Lib\site-packages

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.

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