Can anyone please help how do i change the chrome settings in selenium using pytest to download files to a desired location.
what should i add to the below command in run configurations of eclipse to change the download path
--baseurl='http://example.com'--driver=chrome
In Python itself, it would be:
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_experimental_option("prefs", {"download.default_directory": "some/path", "download.directory_upgrade": true})
driver = webdriver.Chrome(executable_path="the/path/to/the/driver.exe", chrome_options=chromeOptions)
Related: https://bugs.chromium.org/p/chromedriver/issues/detail?id=330
If I understand correctly how this "Pytest_mozwebqa" thingy works, you could try adding this command line:
--chromeopts='{"prefs":{"download.default_directory":"some/path","download.directory_upgrade":true}}'
Related
I use VS Code Version: 1.74.3 on MacOS 13.2. python -V returns Python 3.11.1.
I get the following error message: Import "django.shortcuts" could not be resolved from source Pylance(reportMissingModuleScource).
As you can see in the screenshot, the correct venv is activated and includes Django.
I also tried or checked:
Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10
https://stackoverflow.com/a/65802367/2321643 but
the suggested solution with reloading the windows did not help.
reinstallation the virtual environment within VSCode and installing Django again
re-selecting the venv.
deleting all python-specific settings in user/settings.json as well as .vcode/settings.json.
Reinstallation python and associated extensions.
Using Debug I can safely run my Django-application without any import issues. What do I need to do that Pylance does not issues these problems?
My issue was a bug, fixed and closed.
For reference: https://github.com/microsoft/pylance-release/issues/3881
Try clicking on where it says "3.11.1 ('.venv': venv)" (near the bottom right).
It should bring up a little dialog sort of thing at the top where you can verify that the Python path is correct.
Check that it is using the correct Python path. It should be something like venv/bin/python3 or venv/bin/python assuming venv is situated at the root of youur project.
So i'm studying python crashcourse and after finishing the basics I jumped to the django project.
I created a virtual env, installed django and created an app with manage.py startapp command.
I use Visual Studio Code, and the problem is when I go to models.py it gives an error that it's unable to find django.db module
unable to import error
Now I understand this is because of the file structure, which is as per my research the correct one, and I followed the book carefully, however i don't know how to fix this and I feel that i'm missing something.
This is my file structure for the virtual environment
file structure
Any idea how to fix it ? :)
Thanks in advance
Thank you Incognos !
To be more specific The solution was :
enter "code ." in the terminal and then a new VS opens.
Ctrl+Shift+P -> Select Interpreter
select the environment that starts with ./env or .\env
run Ctrl+Shift+` to activate it
VS is not seeing your virtualenv. You need to activate it for VS code so that it knows that django is installed in the virtualenv see https://code.visualstudio.com/docs/python/environments
it happens because pylint is installed outside your virtual environment. So install pylint inside virtual environment with this command (pip install pylint).
Note: If you're using Visual Studio Code - Insiders you'll use code-insiders . instead of the code . command.
Then, a new window will open and you can set your virtual environment interpreter there.
Reference: https://github.com/Microsoft/vscode/issues/6627
in my case, the problem was solved by opening VS-Code in the directory where virtualenv is located.
Click Ctrl-shift-p to access the Command pallete, then search for Python: Select Interpreter. Click on it and then select on the one that has been recommended by the editor.
(Modified to answer the questions in the first comment.)
I am using Flask in PyCharm and getting different results than when I run it from the terminal. In particular, the working directory of the Python program is different under Pycharm. So this code works correctly when running flask from the command line and the print os.getcwd() displays '/Users/Wes/Dropbox/Programming/Python/etpruncnt2'.
However if I run the same code in Pycharm the os.getcwd() displays '/Applications/PyCharm.app/Contents/bin' and the file open fails
with IOError: [Errno 2] No such file or directory: 'data/results.json'.
The root of the project in PyCharm is /Users/Wes/Dropbox/Programming/Python/etpruncnt2. I have also added a screenshot of the project structure in the PyCharm GUI.
I suppose I must have the configuration wrong in PyCharm. I have included a screenshot.
What should I do?
#app.route('/running_count')
def running_count():
print os.getcwd()
with open('data/results.json', 'r') as resultFile:
resultData = json.load(resultFile)
return str(resultData)
You Only Have Shown Script Path
How is project structure ? When you are creating new project you are telling pycharm the project root and may you mixed that part :)
I am going to close this. The immediate problem is that the Working Directory in the config was not filled in.
Most default setups for PyCharm do fill that in, but the setup for flask does not.
I have filed a low-urgency bug report with IntelliJ.
I've just started developing a new application using Flask and PyCharm as my IDE.
I've encountered a problem which is driving me crazy.
Here is the code. I'll spare use all the import part and so on, I'll show only the routes that cause problems.
#app.route("/")
def home():
return render_template("home.html")
#app.route("/login/")
def login():
return "foo"
The first route works without a problem. However on the first line of the second route, PyCharm gives me an error message '"#" or "def" expected'. This breaks the autoindent and the auto completion features.
But the code runs without a problem.
Can anyone tell me how to fix this?
Thank you
This is because PyCharm is not able to recognize the flask package or version.
Once you add new project to PyCharm -
Go to File menu item
Click on Settings option
This will open-up the pop-up window.
In the left-hand-side link list - click on the project name
Click on the Project Interpreter link
In the right-hand-side pane select Flask and related packages that your project needs and add/install the same.
What worked for me was (I was missing pycharm's python environment dependencies for python)
If you don't already have a requirements file for your project.
Navigate to your project & this on your command line (as I used a venv virtual environment):
(venv)$ pip freeze > requirements.txt
Then Open your pycharm and open the requirements file, wait a second or two and a pop up notification will show up at the top showing you are missing dependencies and will provide you a click here to install.
After that I had no issues.
path : C:\Ruby193\bin;C:\Program Files\Kerio\Outlook Connector (Offline Edition)\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0\bin;%ANT_HOME%\bin;D:\Automation\android-sdk;D:\Automation\android-sdk\tools;D:\Automation\android-sdk\platform-tools
ANDROID_HOME : D:\Automation\android-sdk
JAVA_HOME : C:\Program Files\Java\jdk1.7.0
C:\Users\nanda.kumar\Desktop\bbb>calabash-android console D:\Automation Tools\Calabash_Requirements\7.1.2com.
tesco.grocery.view-Aligned.apk
After the above step,I am getting the following error
Could not find an Android SDK please make sure it is installed.
You can read about how Calabash-Android is searching for an Android SDK and how you can help here:
https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites
Android SDK is installed and it is working fine with Robotium. I don't know what is wrong here. can anyone help me with this ?
According to the following
https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/env.rb
def self.path_if_android_home(path)
path if path && File.exists?(File.join(path, 'platform-tools', adb_executable))
end
$ANDROID_HOME/platform-tools/adb must exist
It seems that in the new ANDROID SDK, it’s in the bin folder, so i just created a symlink “platform-tools” to the “bin” directory.
Hope this helps
Samir
Can you please set your android home on path as
%ANDROID_HOME%/platform-tools;%ANDROID_HOME%/tools the same applies with JAVA_HOME as well.So your path should look something like this
path : C:\Ruby193\bin;C:\Program Files\Kerio\Outlook Connector (Offline Edition)\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.7.0\bin;%JAVA_HOME\bin;%ANT_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\tools;
Try this and see. Running adb should you the commands of android?
Regards,
Sai
I would suggest including the path of android tools in the environment variables in the drive where OS is installed(C drive) and reboot the machine. Let me know if this helps
ANDROID_TOOLS=C:\Automation\android-sdk\tools\
ANDROID_PLATFORM_TOOLS=C:\Automation\android-sdk\platform-tools\