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.
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
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
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~~~
I'm making a RIDE test projet to exécute the following test:
- open chrome browser at a URL than to make a screen shot to compare it with an other image.
here is the test cass:
*** Settings ***
Library Selenium2Library
*** Test Cases ***
TC1
[Documentation] Ouvrir extremeexcelsolutions.weebly.com \ \ sur chrome et vérifier les éléments.
Open Browser https://extremeexcelsolutions.weebly.com chrome
Click Element xpath=//li[#id='pg224152549677137323']
Sleep 10s
${text}= Get Text xpath=//*[#id="wsite-content"]/div[2]/div/div/table/tbody/tr/td[2]/div[2]
Log ${text}
CT2
Library Screenshot
I'm wonderng how to make the scren shot.
thank you.