Robotframework: no keyword with name 'open browser' found - selenium

I am trying to create a simple robot framework test, but when i run the following code, the test fails saying that there's no keyword for 'open browser'. It looks like the selenium library is not recognized, but I cannot understand why, as I have the required plugins installed (intellibot and robotframework support)
*** Settings ***
Documentation Testing
Library SeleniumLibrary
Library AngularJSLibrary
*** Variables ***
${BROWSER} chrome
*** Test Cases ***
Testing
begin web test
*** Keywords ***
Begin web test
open browser about:blank ${BROWSER}
maximize browser window

It seems that the Selenium library is missing from Machine. Following step can be done.
In the command prompt :
run command : pip list
It should contain following library : robotframework-seleniumlibrary
If not then install : python -m pip install robotframework-seleniumlibrary
Also then the IDE can be checked with the Interpreter or venv list of packages added in the project has the robotframework-seleniumlibrary added.

Did you install robotframework-seleniumLibrary?? You can install by executing following command.
pip install --upgrade robotframework-seleniumlibrary
Official Page for reference: official robot framework selenium library documentation. Also you need to have chrome drivers installed Download Chrome Driver.

Related

Chromedriver can’t be opened because Apple cannot check it for malicious software

Environment:
OS : Big Sur 11.1
Homebrew 3.2.13
Python 3.9.7
Command:
chromedriver —version
Error GUI Alert:

Error via output of .py file attempt to run chromedriver:
raise WebDriverException(selenium.common.exceptions.WebDriverException: Message: Service /opt/homebrew/bin/chromedriver unexpectedly exited. Status code was: -9
Fix Method (1)
As stated in the alert, try updating chromedriver:
Uninstall the current version:
brew uninstall chromedriver
Verify that chromedriver is uninstalled:
brew info chromedriver
Install the newest version of chromedriver:
brew install chromedriver
You can also try:
brew reinstall chromedriver
Fix Method (2) : Still Stuck
If you are still experiencing the issue, this fix helped me.
Determine which chromedriver is being used, run:
which chromedriver
Result :
/opt/homebrew/bin/chromedriver
Use the path to chromedriver in the following command to unblock it.
xattr -d com.apple.quarantine /opt/homebrew/bin/chromedriver
Now run the following:
chromedriver —version
Result :
ChromeDriver 93.0.4577.63
Chromedriver should successfully execute.
Reference
coorasse's answer.
For downloading from the chrome drive website
this one worked for me for MAC m1 chip
Use the path to chromedriver in the following command to unblock it.
xattr -d com.apple.quarantine path/to/chromedrive
I had the same issue this morning, this is what fixed it for me.
Go to the system and preferences -> security and privacy.
Then under general tab you will see a notification that about the
exec you are trying to open.
Just click "open anyway" there.
Go back to the chromedriver exe and open it it will then give you the same error but along with that you will get an option to open it.
Click Open and it should resolve.
Worked for me.

Azure pipeline run selenium script

I have a Selenium automation that I wrote in python to test the workflow of my website.
In my script I set a PATH and a webdriver as follow:
PATH = "<path-to->/ChromeWebDriver/chromedriver"
driver = webdriver.Chrome(PATH)
Goes without saying that this works just fine and without any issue. and I am able to run my script.
Now I wanted to try to integrate this script in a azure DevOps pipeline to automate this script every tot hours.
but I am getting and error (reasonable error) during the pipeline trigger.
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
I understand that the PATH I have declared in my code, it won't work as not different, but how can I configure my pipeline to add the chrome driver to a windows vm during the process?
because I have a yaml file that is configured as follow
trigger:
- master
variables:
vmImageName: 'ubuntu-latest'
steps:
- task: UsePythonVersion#0
inputs:
versionSpec: '3.x'
addToPath: true
- script: |
python -m pip install --upgrade pip
pip install selenium
- task: Pythonscript#0
inputs:
scriptSource: 'filePath'
scriptPath: './test.py'
Is there a way how I can set the path? thank you so so much in advance
EDIT:
I did something different. In my repo I added ubuntu chrome driver and pointed my PATH to that folder. When I run the pipeline in azure, I get this error.
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Problem solved, I have to download chrome driver for ubuntu, change my configuration pipeline to run on a ubuntu vm, and create a folder with the chromedriver where my pipeline was. and deploy everything.

How to use Webdriver manager in Robot Framework?

In selenium I used webdriver manager through a command:
driver = webdriver.Chrome(Chromedrivermanager().install())
Is there a webdriver manager use for the robot framework? I would like the webdriver manager to download automatically when running the test script without additional interference.
My solution for using this with Robot Framework was with a python library that I called chromedriversync.
chromedriversync.py:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
def get_chromedriver_path():
driver_path = ChromeDriverManager().install()
print(driver_path)
return driver_path
Then, in my robotframework tests, I add
Library chromedriversync.py
${chromedriver_path}= chromedriversync.Get Chromedriver Path
Create Webdriver chrome executable_path=${chromedriver_path}
Go to www.google.com
I just use the chromedrivermanager install method's returned path variable, to supply to the Open Browser Robot Framework keyword.
The only thing that i found in internet is that Youn need to install webdrivermanager with command :
pip install webdrivermanager
and you launch this command before your script:
webdrivermanager chrome
robot --outputdir ./results/Robot-results ./TestSuits/*
NB: your browser (Chrome) has to be updated too : (Ubuntu)
sudo apt-get update
sudo apt-get install google-chrome-stable
There are two web driver managers as shown below,
If you use this one, you need to do one additional step on the command line, you cannot proceed with the test code unless you execute the below command, as this is part of the webdrivermanager setup.
webdrivermanager -
webdrivermanager 0.7.4
command-line step -
webdrivermanager chrome:2.38 firefox opera:v.2.35
webdriver-manager 2.3.0
You need to do the following to use webdriver-manager, did you notice something, there is nothing which needs to be done anything specific to webdriver-manager, BEAUTY of making use of robotframework. nice!!!
code
1. pip install webdriver-manager robotframework robotframework-seleniumlibrary
(prjenv) 09:37 PM##~::>pip list
Package Version
------------------------------ ----------
certifi 2018.11.29
chardet 3.0.4
colorama 0.4.1
configparser 4.0.2
crayons 0.3.0
idna 2.8
pip 19.2.3
requests 2.22.0
robotframework 3.1.2
robotframework-seleniumlibrary 4.1.0
selenium 3.141.0
setuptools 40.8.0
urllib3 1.25.6
webdriver-manager 2.2.0
wheel 0.32.3
2. create a file sample.robot
***Settings***
Library SeleniumLibrary
***Test Cases***
Sample Webdriver
[Tags] wd0
[Documentation] Sample invocation using WD
Open Browser http://google.com ff
Close All Browsers
3. execute the file as follows
robot *.robot
Output
========
(prjenv) 09:38 PM##~::>robot *.robot
==============================================================================
Sam
==============================================================================
Sample Webdriver :: Sample invocation using WD | PASS |
------------------------------------------------------------------------------
Sam | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: /Users/apachemain/output.xml
Log: /Users/apachemain/log.html
Report: /Users/apachemain/report.html
THAT'S IT!!!
in the cmd terminal
pip install webdrivermanager
webdrivermanager firefox chrome --linkpath /usr/yourdir
as for automatic updates you could make a batch file .bat (just cmd input) with the last command (it will update the version automatically) and set it to a windows scheduler
https://www.windowscentral.com/how-create-and-run-batch-file-windows-10
https://www.digitalcitizen.life/how-create-task-basic-task-wizard

I am failing to install Selenium module via command line

I use Ubuntu 16.10. I tried installing Selenium module of python via the command - sudo pip3 install -U selenium. But, I am not able to install it. It is giving an unexpected error. I am sharing the screenshot of the terminal here. Please help!
Please click here for the screenshot
If you are using Ubuntu, I'd suggest checking in the package manager as it may already be there. I'm on Mint and it was already there when I loaded python (2.7 also).

PHPunit test failed with Yii framework

My local system is WAMP (win 8.1) with Yii 1.1.14.
I had installed PHPUnit by pear.(CMD: pear install phpunit/PHPUnit)
But the test failed.
Could someone give me some hint? Many thanks.
Following is the error message.
C:\wamp\www\trackstar\protected\tests>phpunit --version
PHPUnit 4.0.14 by Sebastian Bergmann.
C:\wamp\www\trackstar\protected\tests>phpunit unit/DbTest.php
PHP Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php): failed to o
pen stream: No such file or directory in C:\wamp\www\yii\framework\test\CWebTest
Case.php on line 12
You have to install some extension, in this case Selenium. I assume you run selenium tests and that is you you have to extend that.
In Linux you would have to install it with
pear install phpunit/PHPUnit_Selenium
Not sure quite what the command is in Windows.