RIDE can't find firefox geckodriver while running screen-test - selenium-firefoxdriver

I have a 'hello world' test to open a browser using firefox.
The test runs fine on the commandline ($ robot hai_world.robot).
But it fails when I run the test in RIDE. It reports:
WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Does RIDE have its own PATH-setting?
It runs on ubuntu 20.04 in RIDE v2.0b1 on Python 3.8.10

Because your geckodriver is in a location defined in PATH only for your user, RIDE does not know of this when started from the shortcut.
I see (at least) two options to fix this:
Create a link to geckodriver in a global PATH location, for example:
sudo ln -s /home/hobijn/.local/share/WebDriverManager/bin/geckodriver /usr/local/bin/geckodriver
Modify the launcher script of RIDE to have PATH updated:
export PATH=$PATH:/home/hobijn/.local/share/WebDriverManager/bin ; python3 -m robotide.__init__ $*

Related

why pyinstaller kepp throwing codesign failure while my script has been signied?

im on macbook old version El Capitan 10.11.6 and my python script is 147bytes just for auto shutdown program but when i try to boundle it pyinstaller filename.py it done almost everything and end up with (codesign failure). do someone know how to solve this?
Try the following command in your terminal, type: sudo codesign -f -s followed by your script name test.py Make sure you are in your script file directory by using cd path to your file folder.
After that, you can run pyinstaller test.py However, I am using macOS Monterey Version 12.6 and am not sure if it will work on your current version. In fact, I don't even know how that command makes it work, but it works for me. If your app is a windowed app, such as the Tkinter app, your system may prevent it from opening; in that case, use the following command to disable the security system sudo spctl --master-disable . then you will see a new option available in your macOS Settings under Security; down there it says Allow app from: App Store, App Store and identified developer; and at last, you will see a new option "Anywhere" which wasn't there before; check that, and your app will work perfectly. hope helped

Open terminal in XFCE from script and activate python virtualenv

I try to open terminal in XFCE and activate python3 virtualenv using the following line in a bash script:
xfce4-terminal --working-directory=$HOME/path/to/project --maximize \
-e 'bash -c "source $HOME/path/to/project/venv/bin/activate; bash"'
The strange thing is that the virtualenv gets kind of activated since:
which python
shows the correct path to the virtualenv directory and the project seems to be working fine.
However I don't see the (venv) to the left from the shell prompt. Moreover, when I enter deactivate it complains that no such command can be found.
Is there a proper way to solve this problem?
I created a bash shortcut for this in my /Users/username/.bash_profile (I use mac; on linux use Users/username/.bashrc instead).
function pcd() {
cd /Users/username/Code/"$1"_env/"$1"
source ../env/bin/activate
atom -a .
}
Where project_env is the root folder, which contains the venv, and the project folders (project folder is where code goes)
to execute this simply call pcd project
I don't know much about bash, so I can't really tell you why your code doesn't work.
Also, make sure you open a new terminal window after saving this.

Python3 GUI script does not work when double clicked

My GUI script that is a PyQt5 file (.pyw extension) does work when running on my IDE with a build configuration that tells the compiler to run the script with python3:
And it also works when i tell to the regular terminal on Linux to run same script with python3 like this:
When runned with the default python (python2.7) on a regular terminal it tells: ImportError: No module named PyQt5.QtWidgets.
My code does it have these lines on the start to tell that is a python3 script like: #!/usr/bin/python3 or #!/usr/bin/env python3 (I have python3 installed).
When double clicked on the Linux Mint File Explorer the cursor turns crosshair and nothing happends, with the terminal option, same happends and a empty terminal shows. Im talking these options
I guess Linux Mint still runs the scripts with python2.7 even when I added the bash lines to tell
Someone knows why the lines:
#!/usr/bin/python3
#!/usr/bin/env python3
doesnt work when just double click?
I want to run the script from the Linux File Explorer without the need of an IDE or using the terminal.
Try chmod +x file.py and run it in terminal by using ./file.py also try lunching the file from a different path, like python3 ~/path/to/file.py and see if the error persists

How to add Chromedriver to PATH in linux?

Trying to use Selenium with Chrome in a python script.
I get the following error:
WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
I know the location of the chromedriver executable.
How do I add it to the PATH?
thank you
You can specify the absolute path to your chrome driver in your script as such:
from selenium import webdriver
driver = webdriver.Chrome(executable_path='/path/to/driver/chromedriver')
Or you can add the path to your webdriver in the PATH system variable as so:
export PATH=$PATH:/path/to/driver/chrome-driver
You may add the above line to your /home/<user>/.profile file to make it permanent.
Tested on Ubuntu 17.10 running Python 2.7.14
Hope this helps!
The solution posted by #AnythingIsFine is indeed correct.
However in my case my pytest was still unable to find the chromedriver (despite it was correctly added to the PATH and from the terminal I could execute it).
So I've solved by adding an alias of the chromedriver in the /usr/bin directory:
sudo ln -s /path/to/chromedriver /usr/bin
Move Chromedriver to path with:
sudo mv -f ~/chromedriver /usr/local/bin/chromedriver
/usr/local/bin/chromedriver is path.
For selenium framework (python or java), Browser driver(chrome/firefox/ etc.) should be saved on the Path " /usr/local/bin/chromedriver & /usr/bin/chromedriver"
For Chrome Driver Link : https://chromedriver.chromium.org/downloads
go to the link and download the chrome driver for corresponding OS.
Linux:
Open the terminal on the Saved/downloaded directory then enter the command
"sudo mv /path/to/chromedriver /usr/bin"
"sudo mv /path/to/chromedriver /usr/local/bin"

unable to run PhantomJS under cygwin using absolute paths

I am not able to run PhantomJS under cygwin using absolute paths for the argument .js file. Here are the steps I took to setup PhantomJS:
Downloaded PhantomJS 1.9.7 for windows
Copied the PhantomJS executable to c:\cygwin64\bin\
Copied the file "hello.js" from the unzipped PhantomJS download file to my cygwin home directory
Started cygwin/xterm
If I run:
which phantomjs
in my cygwin xterm, it correctly responds with:
/usr/bin/phantomjs
If I run the following from my home directory:
phantomjs hello.js
PhantomJS correctly responds with:
Hello, world!
If I on the other hand run this:
phantomjs /home/user1/hello.js
PhantomJS replies:
Can't open '/home/user1/hello.js'
If I run this:
/usr/bin/phantomjs /home/user1/hello.js
PhantomJS still replies:
Can't open '/home/user1/hello.js'
It does this for every absolute path I try. Why won't PhantomJS work with absolute file paths? The path I showed in my example doesn't have any spaces, special characters, etc., so I'm not sure what the problem could be.
I also tried running the same test in a command prompt under windows and sometimes it would exhibit the same behavior, but not always. I can't seem to reproduce this error under windows anymore so I'm not sure what else to say about that.
Does anyone know what the problem could be?
I found the solution. Running native windows programs through cygwin requires you to convert cygwin's POSIX paths to Windows-style paths. In my example above, the following works:
phantomjs "`cygpath -w /cygdrive/c/cygwin64/home/user1/hello.js`"
returns:
Hello, world!
I am not yet sure what the backticks are for, but at least I found the solution.

Resources