Getting error while selecting Salesforce Lookup window - robotframework

*** Setting ***
Library DateTime
Library OperatingSystem
Library Selenium2Library
Suite Teardown Close Application
Resource ../Custom Keywords/BrowserKeywords.robot
*** Test Cases ***
Create Case
Open Browser https://login.salesforce.com/ chrome
Sleep 5s
Maximize Browser Window
Input Text //input[#id='username'] XXXXXXXXXXXXXXXX
Input Password //input[#id='password'] XXXXXXXXXXXXXX
Click Button //input[#id='Login']
Sleep 2s
Click Element //li[contains(#id,'Case_Tab')]
Sleep 2s
Click Button //input[contains(#name,'new')]
Sleep 5s
Click Image //img[#alt='Contact Name Lookup (New Window)']
sleep 15s
Select Window title='Search ~ Salesforce - Developer Edition'
Sleep 5s
Select Frame //frame[#id="searchFrame"]
Input Text //input[#id='lksrch'] Test
Click Button //input[#name='go']
Close Window
Close all Browsers
Output:
KEYWORD Selenium2Library . Select Window title='Search ~ Salesforce -
Developer Edition'
Documentation:
Selects the window matching locator and return previous window handle.
Start / End / Elapsed: 20170801 12:40:14.275 / 20170801 12:40:14.701 /
00:00:00.426
00:00:00.339 KEYWORD Selenium2Library . Capture Page Screenshot
12:40:14.700 FAIL NoSuchWindowException: Message: no such window
(Session info: chrome=59.0.3071.115) (Driver info:
chromedriver=2.29.461591
(62ebf098771772160f391d75e589dc567915b233),platform=Windows NT
10.0.10586 x86_64)

I don't know if this is the only problem, but part of the problem is the quotes you have around the title. Unless the actual title has actual quotes, you need to remove them.
Select Window title=Search ~ Salesforce - Developer Edition

Related

How to make the browser allow notification disappear while running automate test using Robot Framework

I don't want Allow Notifications pop up appear while I'm running automate script and I try to block it by manual (block it in browser setting). Browser is Firefox.
Test
[Tags] Regression
Open Excel ${Data.${ENV_DATA}}
#{getCustInfor}= Get Sheet Values CardNo
#{getMsg}= Get Sheet Values Messages
Login.Login by username and password ${USER.${ENV}} ${PASS.${ENV}}
The pop up always shows after finished login page and it cover some element.
Set the preference of firefox dom.webnotifications.enabled to False. This will disappear the notification.
In robot you can do this by, creating a function
def create_profile(self):
from selenium import webdriver
fp=webdriver.FirefoxProfile()
fp.set_preference("dom.webnotifications.enabled",False)
fp.update_preferences()
return fp.path
In .robot file add the following code:
${profile}= create profile
Open Browser ${URL} ${BROWSER} ff_profile_dir=${profile}

Robot framework, chrome new tab issue

I have a simple Robot Framework script
*** Settings ***
Documentation Simple Amazon.in demo
Library SeleniumLibrary
*** Variables ***
${MESSAGE} Hello, World
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about the test
[Tags] Smoke
Open Browser http://www.amazon.in chrome
Input text id=twotabsearchtextbox Ferrari 458
Click Button xpath=//div[#class='nav-search-submit nav-sprite']/input[#class='nav-input' and 1]
Wait until page Contains results for "Ferrari 458"
Click Link css=#result_0 a.s-access-detail-page
Wait until Page Contains Back to search results for "Ferrari 458"
Click Button id=add-to-cart-button
Wait Until Page Contains 1 item added to Cart
But whenever chrome reaches Click Link css=#result_0 a.s-access-detail-page it opens a new tab, and my robot script fails. How can I rectify it. Please help
You can use the select window keyword and Get Window Titles keyword to navigate between them Get Window Titles keyword will return a list of titles the last index in that list is the new tab that has been opened, to access it from the list you can do the following ${Tabs[1]} (as in this code there is only 2 values in the list)
*** Settings ***
Documentation Simple Amazon.in demo
Library SeleniumLibrary
*** Variables ***
${MESSAGE} Hello, World
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about the test
[Tags] Smoke
Open Browser http://www.amazon.in chrome
Input text id=twotabsearchtextbox Ferrari 458
Click Button xpath=//div[#class='nav-search-submit nav-sprite']/input[#class='nav-input' and 1]
Wait until page Contains results for "Ferrari 458"
Click Link css=#result_0 a.s-access-detail-page
${Tabs} = Get Window Titles
select window title=${Tabs[1]}
Wait until Page Contains Back to search results for "Ferrari 458"
Click Button id=add-to-cart-button
# Wait Until Page Contains 1 item added to Cart
Wait Until Page Contains Added to Cart
Results:
==============================================================================
Amazon :: Simple Amazon.in demo
==============================================================================
User must sign in to check out :: This is some basic info about th...
DevTools listening on ws://127.0.0.1:29864/devtools/browser/75b8be3c-6e76-474f-b391-d340fb322895
User must sign in to check out :: This is some basic info about th... | PASS |
------------------------------------------------------------------------------
Amazon :: Simple Amazon.in demo | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Output: C:\development\robot-scripts\sssss\output.xml
Log: C:\development\robot-scripts\sssss\log.html
Report: C:\development\robot-scripts\sssss\report.html
I changed the last line of your code as it wasn't a valid text. See the comment in the code.

How to run keywords into multiple times

My scenario:
There is field called "search first value" i have to click on Then click on Submit.
I have to repeat this step more than 100 times. How can i do in Robot framework?
MY code:
[Documentation] Resubmit
wait until element is enabled ${CLICK_RESUBMIT}
click element ${CLICK_RESUBMIT}
sleep 2s
confirm action
repeat keyword 5times Go to Previous Page
Standard library have keyword Repeat Keyword
http://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Repeat%20Keyword

Select window created using JavaScript

In My Robot Script , After clicking on Edit Description link a window get opens (i.e. Java Script Window) Images here
Image 1::
Image 2:: Window image Along with Page Source
What i need is a. Select the window (java script)
b. Enter text into Text Area and click Ok.
I tried to use Select Window new/ Select window Description But control is waiting infinite # Select Window key word its not moving forward. I have to kill Control forcefully.
*** Settings ***
Documentation Suite description
Library Selenium2Library run_on_failure=Nothing
Library Collections
*** Test Cases ***
Log into Command center
[Tags] DEBUG
open browser http://11.8.180.***/BCC ie
input text xpath=//*[#id='LoginName'] User
input password Password Pwd#123
click element LoginBtn
wait until keyword succeeds 30 sec 5 sec page should contain element AppTitle
sleep 3s
${Title} Get Page Title
log ${Title}
Navigation to Usrs
Click on Window popup and enter text
CloseBrowser
close all browsers
*** Keywords ***
Click on Window popup and enter text
Click Link //*[#id="aspnetForm"]/table/tbody/tr[1]/td[2]/a
Sleep 5s
Select Window By Unique Identifier Element With Delay //*[#id="descript"]
Select Window By Unique Identifier Element With Delay
[Arguments] ${element} ${delay_time}=10
sleep ${delay_time}
#{wins}= Get Window Handles
Log ${wins}<--these are window names console=true
:FOR  ${windowName}  IN  #{wins}
\   Log ${windowName} console=true
\ run keyword and ignore error Select Window  ${windowName}
\   ${found_flag}= run keyword and return status page should contain  ${element}
\   Run keyword if ${found_flag} input text ${element} this is text
\   exit for loop if ${found_flag}
Get Page Title
Log Control came to GET PAGE TITLE
run keyword and return Get Title
Navigation to Usrs
Go to http://11.8.180.***/BCC/role.aspx
Any Idea how to select new window? and enter text hit okay.
A.Get Window Identifiers --> Jus hangs it neither moves nor throw any error
B. Get Window Names gives this error {URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>..}.
C. Get Window Handles returns this { [u'b0ce0f28-f6d4-4943-93f7-f65fd5f1de2a', u'c0442110-4ea9-40a4-b126-eee09d9f3eb0']}
I am not sure how to identify which window have these id's
Thanks in Advance
It should be recognized as new window in your browser, so you can use:
Select Window Description

Unable to startup test. Unknown tests gets called for Robot Framework Test Execution

I'm surprised to see this error message when executing Test Automation using RobotFramework with RED editor. Plz guide me on this issue getting rectified.
I dont have any test case called "Filter the customer". When running my suite it shows up the below error.
Note: I did the below, even then I'm having this issue.
1. I cleaned the Project
2. I also deleted and re-added the modified libraries.
3. Saved all the updated files.
Error:
The source is as below,
*** Setting ***
Resource ../KCC_Automation/ResourceFiles/KCC_Resource.txt
*** Test Cases ***
Login with valid credentials
Logon to KCC browser
Enter User Name
Enter Password
Click Login
Show Customers available in Customer List Page
Get the customer names and click them from Customer List Page
Begin the New Assessment for an opportunity
Filter by Customer Search
Expand the customer details and begin the New Assessment
Stop Testing
Logout of KCC
And the resource file is as below,
*** Keywords ***
Welcome1
${message} say hi
Log ${message}
Welcome2
${message} say hi Testers
Log ${message}
Welcome3
${message} type of 42
Log ${message}
Logon to KCC browser
Open Browser ${LOGIN URL} ${BROWSER}
Wait Until Page contains Element ${UserName_Field}
Enter User Name
Input Text ${UserName_Field} ${USERNAME}
sleep 2s
Enter Password
Input Text ${Password_Field} ${PASSWORD}
sleep 2s
Click Login
Click Element ${LoginButton}
sleep 5s
Get the customer names and click them from Customer List Page
set selenium speed 5s
wait until element is visible ${customers_grid}
wait until page contains element ${customers_grid}
sleep 3s
#{customers} get webelements ${customer_list}
${items} Store Texts #{customers}
#${items} storeTexts #{customers}[2]
${store} get text ${items}
Log ${store}
Filter by Customer Search
set selenium speed 5s
input text ${Customer_Search} ${Search_Text}
sleep 3s
${Entered_text}= get value ${Customer_Search}
should be equal ${Search_Text} ${Entered_text} The given message is incorrect true
Expand the customer details and begin the New Assessment
wait until page contains element ${customer_list}
click element ${customer_list}
sleep 2s
click element ${opportunity-status}
sleep 2s
click element ${forward_button}
sleep 2s
click element ${Btn_Add_Building}
sleep 2s
Logout of KCC
In the source file, I re-placed the test case name "Begin the New Assessment for an opportunity" by "filter the customers" as because earlier i named this testcase like this, executing it showing up below issue now, Is this RED editor issue?
[ ERROR ] Unexpected error: NoClassDefFoundError:
org/openqa/selenium/WebElement
java.lang.NoClassDefFoundError:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at robot.utils.importer$py.import_$32(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:274)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py._import_class_or_module$5(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:77)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py.import_class_or_module$4(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:74)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.model.visitor$py.visit_suite$2(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit$19(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit$11(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite$2(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit$19(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.utils.application$py._execute$10(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:94)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at robot.utils.application$py.execute_cli$5(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:49)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at runpy$py._run_code$9(C:\jython2.7.0\Lib\runpy.py:73)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
at runpy$py._run_module_as_main$14(C:\jython2.7.0\Lib\runpy.py:161)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebElement
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 191 more
Looking at the error it seems to me that you don't have the Selenium2Library loaded Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebElement You can load a library by using the syntax:
*** Settings ***
Library Selenium2Library
Please keep in mind that this library requires either a pip install robotframework-selenium2library or to install the Java Port of the Selenium2Library
Although I can't be sure, I suspect that when this issue is resolved your other problem is also fixed.

Resources