In my settings
*** Settings ***
Library SeleniumLibrary
is written this way, but somehow the robotframework adds a space in between when I try to run the test and I get this ERROR "Non-existing setting 'Library Selenium Library'". Any ideas why? everything should be the latest version. I have tried also with Selenium2Library.
pip install --upgrade robotframework-selenium2library
make sure you have installed it as above and use it as :
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Input Text
Open Browser https://www.google.com chrome
Related
I want to Open browser in Edge with IE mode.
My environment: IE7, windows 11, Python 3.10.4, Edge version 108.0.1462.46
And I follow the required configuration from below:
https://www.selenium.dev/documentation/ie_driver_server/
I made the same value for Enhanced Protected Mode by setting the REG_DWORD 2500 value to 0 in Zones 0,1,2,3,4:
Registry Editer path: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
I add the IEDriverServer to my PATH
Is there any wrong steps about my configuration?
Below is my code:
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${IEDriver} D:\\IEDriver\\64bits\\IEDriverServer.exe
*** Test Cases ***
Example Test
Open Browser https://www.google.com.tw/ ie executable_path=${IEDriver} options=ignore_zoom_level=True; attach_to_edge_chrome=True; edge_executable_path="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
Maximize Browser Window
After I executing my code, I can open google in Edge with IE mode, but after that web page stuck and always get thie error message:
TimeoutException: Message: Timed out waiting for page to load.
And I found something interesting: I use python and selenium and below is my code:
ieOptions = webdriver.IeOptions()
ieOptions.add_additional_option("ie.edgechromium", True)
ieOptions.add_additional_option("ie.edgepath",'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe')
driver = webdriver.Ie(options=ieOptions)
driver.maximize_window()
driver.get('https://google.com')
driver.quit()
If I remove this line "driver.get('https://google.com')" and my code runs perfectly.
But If I add it back, the page will go to goole and stuck there (It means that this code will not do driver.quit()
This option may work for you in Windows 11 IE mode automation. Check it out:
ignore_protected_mode_settings = True
UPDATE
Or you can simply try setting the page load timeout according to your requirement:
*** Variables ***
${orig timeout} 15 seconds
*** Test Cases ***
Example Test
Set Selenium Timeout ${orig timeout}
If the element you'd like to interact with has been fully loaded, you can skip the page loading and continue. A native Python example:
driver.set_page_load_timeout(10)
try:
driver.get('https://google.com')
except TimeoutException:
print
'!!!!!!time out after 10 seconds!!!!!!'
driver.execute_script("window.stop()")
In Robot Framework:
*** Test Cases ***
Example Test
Set Selenium Timeout ${orig timeout}
TRY
Open Browser https://www.google.com ie options=ignore_zoom_level=True; attach_to_edge_chrome=True; edge_executable_path="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
EXCEPT '!!!!!!time out after 10 seconds!!!!!!'
Execute Javascript window.stop()
END
Maximize Browser Window
I am trying to run some test with Robot Framework, but when I try this code I get the following error
*** Settings ***
Library SeleniumLibrary
Suite Setup Go to homepage
Suite Teardown Close All Browsers
*** Variables ***
${HOMEPAGE} http://www.google.com
${BROWSER} chrome
*** Test Cases ***
Google mdh and find mdh.se
Google and check results mdh www.mdh.se
*** Keywords ***
Google and check results
[Arguments] ${accept} ${searchkey} ${result}
Click Button class=RveJvd snByac ${accept}
Click Button name=btnK ${searchkey}
Wait Until Page Contains ${result}
Go to homepage
Open Browser ${HOMEPAGE} ${BROWSER}
Keyword 'Google and check results' expected 3 arguments, got 2.
The error is very clear, you are not passing the ${result} argument.
You need to pass one more argument to your keyword "Google and check results". It required totally 3 and ${result} argument is missed here.
I am trying to run a script to search for the keyword "mdh" and to show mdh.se as a result.
I installed robot framework and selenium library and this is my script which I wrote in sublime text and saved as a .robot file.
*** Settings ***
Library Selenium2Library
Suite Setup Go to homepage
Suite Teardown Close All Browsers
*** Variables ***
${HOMEPAGE} http://www.google.com
${BROWSER} chrome
*** Test Cases ***
Google mdh and find mdh
Google and check results mdh www.mdh.se
*** Keywords ***
Google and check results
[Arguments] ${searchkey} ${result}
Input Text class_name=gLFyf gsfi ${searchkey}
Click Button class_name=Tg7LZd
Wait Until Page Contains ${result}
Go to homepage
Open Browser ${HOMEPAGE} ${BROWSER}
When I try to run the script with robot mdh.robot it says there are 5 errors.
C:\Users\malvi\Desktop>robot mdh.robot
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Non-existing setting 'Library
Selenium2Library'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Non-existing setting 'Suite Setup Go to
homepage'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Non-existing setting 'Suite Teardown
Close All Browsers'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Setting variable '${HOMEPAGE}
http://www.google.com' failed: Invalid variable name '${HOMEPAGE} http://www.google.com'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Setting variable '${BROWSER} chrome'
failed: Invalid variable name '${BROWSER} chrome'.
Am I doing something wrong?
Read the error message closely, and take it literally. It is saying there is no setting named Suite Setup Go to homepage, which is a true statement. There is a setting named Suite Setup, however.
You need at least two spaces between a setting name and the setting value.
I would like to enable uBlock Origin plugin as ads on speedtest.net during robot framework test execution as ads completly jeopardize test result.
So far I have created a Python script to create a profile with extension
from selenium import webdriver
class WebDriverProfile:
def create_profile_with_adblock(self, path):
fp =webdriver.FirefoxProfile()
fp.add_extension(extension='d:/pathtoextension/ublock_origin-1.24.0-an+fx.xpi')
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.dir",path)
fp.set_preference("browser.helperApps.neverAsk.saveToDisk", 'application/csv')
fp.update_preferences()
return fp.path
Also the following robot script to call the function:
*** settings ***
Library Selenium2Library
library Process
library Dialogs
Library WebDriverProfile.py
*** Variables ***
${URL} https://speedtest.net
*** Test Cases ***
Test with speedtest.net
${FF_PROFILE}= Create Profile With Adblock ${TEMPDIR}\\testdirff
Open Browser ${URL} browser=ff ff_profile_dir=${FF_PROFILE}
Execute Manual Step Is adblocker enabled?
The browser will open, but adblocker won't be there.
Anyone could help on this please?
Create webdriver instead of firefox profile and install add-on.
Python extension:
from selenium import webdriver
class WebDriverProfile:
def create_web_driver_with_addons(self):
extension_location='d:\\path_to_adblock\\ublock_origin-1.24.0-an+fx.xpi'
browser = webdriver.Firefox()
browser.install_addon(extension_location, temporary=True)
browser.get('http://speedtest.net')
Robot script:
*** settings ***
Library Selenium2Library
library Process
library Dialogs
Library WebDriverProfile.py
*** Variables ***
${URL} https://speedtest.net
*** Test Cases ***
Test with speedtest.net
create web driver with addons
Execute Manual Step Is adblocker enabled?
You need to create a new browser profile with adblock manually installed firest.
Now, Call the above respective profile the by anyone of the below commands.
Open Browser http://example.com Firefox ff_profile_dir=/path/to/profile # Using profile from disk
Open Browser http://example.com Firefox ff_profile_dir=${FirefoxProfile_instance} # Using instance of FirefoxProfile
Open Browser http://example.com Firefox ff_profile_dir=set_preference("key", "value");set_preference("other", "setting") # Defining profile using FirefoxProfile mehtods~~~
While using AppiumLibrary with RobotFramework, I am getting below error.
Error: importing test library 'AppiumLibrary' failed:
ImportError: No module named switch_to
Here,PYTHONPATH: /usr/local/lib/python2.7/dist-packages/selenium-2.44.0-py2.7.egg
To resolve above error I want to try solution mentioned at link "https://github.com/appium/appium/issues/2625" which asks to remove the lower version of selenium.
I have two selenium folders at below location.
Selenium folders:
1)/usr/local/lib/python2.7/dist-packages/selenium
2)/usr/local/lib/python2.7/dist-packages/selenium-2.44.0.egg-info
How can I remove the the selenium other than 2.44?
No process was required to uninstall Selenium.
I simply deleted the directory "/usr/local/lib/python2.7/dist-packages/selenium". This resolved my error with Robot Framework.