robot-framework error:Message: element not interactable: ElementNotInteractableException - selenium

I am a new in python. Trying to delete a row from a table automatically using robot-framework. Table contained 3 visible rows. Here is my code
*** Settings ***
#Test Teardown Close Browser
Library SeleniumLibrary
Library Stringpip
*** Variables ***
${Reps_Menu_Button} xpath=//div[#data-testid='carrier-reps-list']//div[#data-cellheader='Menu']/button
${reps_Delete_Button} xpath=//reach-portal[13]//div[.='Delete']
${Save_Carrier_Button} xpath=//button[.='Save Carrier']
${Success_Toast} xpath=//div[#class='Toastify__toast Toastify__toast--success']
*** Test Cases ***
#Delete Reps :
wait until element is visible ${reps_menu_button}
click element ${reps_menu_button}
click element ${reps_delete_button}
handle alert ACCEPT
click element ${save_carrier_button}
wait until element is not visible ${success_toast}
Please guide me here. Whether I am missing anything? or doing anything wrong? Thanks in advance :)

Check the variables you created. Variable names are case sensitive.

Related

How to run something after every step in Robot Framework

I'd like to check something after every step in a test case in Robot Framework. I am including a dummy example to represent what I am referring for:
*** Test Cases ***
Order From Somewhere
[Tags] whatever tags here
Step1
#Grab Exception
Step2
#Grab Exception
Step3
#Grab Exception
Step4
#Grab Exception
Step5
#Grab Exception
Step6
#Grab Exception
Step7
I assume there is some way to have '#Grab Exception' executed after every Step, but in a nice way.
Thanks for your help in advance.
You can define your own keyword to do that, for example:
*** Test Cases ***
Test Special Keywords
Special Keyword Sleep 5 seconds
Special Keyword Log <b>This is another keyword</b> HTML
*** Keywords ***
Special Keyword
[Arguments] ${kw} #{arguments}
Run Keyword ${kw} #{arguments}
Grab Exception
Grab Exception
Log Called <i>Grab Exception</i> HTML
You can add something like below in your settings area with Test Teardown option:
Run Keyword If Test Failed or Passed <name of the kw>
--- you can use one of it pass or fail OR you can use Unless a condition met.
e.g. as below:
*** Settings ***
Test Setup Open Application App A
Test Teardown Close Application
*** Test Cases ***
Default values
[Documentation] Setup and teardown from setting section
Do Something
Overridden setup
[Documentation] Own setup, teardown from setting section
[Setup] Open Application App B
Do Something
No teardown
[Documentation] Default setup, no teardown at all
Do Something
[Teardown]
No teardown 2
[Documentation] Setup and teardown can be disabled also with special value NONE
Do Something
[Teardown] NONE
Using variables
[Documentation] Setup and teardown specified using variables
[Setup] ${SETUP}
Do Something
[Teardown] ${TEARDOWN}
Refer more at - https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-setup-and-teardown

How to run if if else condition based on element visibility in selenium robot framework?

I am automating a user registration form flow, where successful registration shows a success message and any validation error throws alert text. For this, I am writing an if-else flow based on the visibility or presence of an element on the page. I will pass the control to a specific keyword with that condition
${SuccessBreadcrumb} is the element which is visible when the registration is successful
Code Snippet
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${SuccessBreadcrumb} = xpath=//a[contains(text(),'Success')]
${SuccessMsgLocator} = xpath=//p[contains(text(), 'successfully created')]
${AlertMsg} = xpath=//div[#class='text-danger']
*** Keywords ***
Verify Validation Message
[Arguments] ${UserDetails}
sleep 2s
run keyword if ${SuccessBreadcrumb} is visible Keyword 1
# ... else Keyword 2
Keyword 1
[Arguments] ${UserDetails}
${AccountCreatedText} = get text ${SuccessMsgLocator}
should contain ${AccountCreatedText} ${UserDetails.ValidateMsg} ignore_case=true
# Keyword 2
Error Log
Run Keyword If ${SuccessBreadcrumb}, is visible, VerifySuccessText
Documentation:
Runs the given keyword with the given arguments, if condition is true.
Start / End / Elapsed: 20200213 12:27:52.882 / 20200213 12:27:52.882 / 00:00:00.000
12:27:52.882 FAIL Evaluating expression 'xpath=//a[contains(text(),'Success')]' failed: SyntaxError: invalid syntax (<string>, line 1)
In the documentation for Run Keyword If there does not exist an example with an object. However, using a combination of Run Keyword If with Run Keyword And Return Status will allow you to create a way to handle pass and fail situations within the same test case or keyword.
*** Settings ***
Library SeleniumLibrary
*** Test Cases ***
Check Element Visible
Open Browser
... url=https://www.google.com
... browser=chrome
${passed} Run Keyword And Return Status
... Element Should Be Visible xpath://*[#id="hplogo"]
Run Keyword If ${passed} Keyword Passed
... ELSE Keyword Failed
[Teardown] Close Browser
Check Element Not Visible
Open Browser
... url=https://www.google.com
... browser=chrome
${passed} Run Keyword And Return Status
... Element Should Be Visible xpath://*[#id="xxxx"]
Run Keyword If ${passed} Keyword Passed
... ELSE Keyword Failed
[Teardown] Close Browser
*** Keywords ***
Keyword Passed
Log To Console Passed
Keyword Failed
Log To Console Failed

Robot Framework: wait until element disappears

I run a test where I have to dismiss a warning that is a DIV that overlays the whole page. First I send a click to a button that adds something, then a warning is displayed. Finally I enter a string in a field
The code looks something like this
SeleniumLibrary.Click element add_button
Wait Until Element is visible warning-overlay-div
SeleniumLibrary.Click element dismiss-warning
SeleniumLibrary.Click element something-else
Running this code results in an error message:
WebDriverException: Message: unknown error: Element <input
type="text" class="upperCaseClass modified" id="something-else"
maxlength="15" style="width: 143px; text-transform: uppercase;"> is
not clickable at point (230, 679). Other element would receive the
click: <div class="warning-overlay-div" style="width: 100%; height:
853px; z-index: 2003;"></div>
That is, I can't click in something-else because warning-overlay-div is on top of it.
Ok, so I added a check to make sure the warning-overlay-div is gone between the the click dismiss-warning and the click on something-else. I have tried multiple variants but these three all give the same result
(from the log)
00:00:15.050KEYWORD SeleniumLibrary . Wait Until Element Is Not Visible ${warning-overlay-div}
00:00:15.003KEYWORD SeleniumLibrary . Wait Until Page Does Not Contain ${warning-overlay-div}
00:00:15.039KEYWORD SeleniumLibrary . Wait Until Page Does Not Contain Element ${warning-overlay-div}
It might take half a second or so for the overlay to disappear but as you can see, all these wait until they timeout after 15 seconds before they return success. I want to continue as soon as the warning-overlay-div is gone, not wait 15 seconds for that.
How do I check that this overlay is gone and then immediately continue?
You could potentially try using "Wait Until Keyword Succeeds" allowing yourself a custom retry timeout. Especially useful if you want to ensure the warning is removed from display in an appropriate amount of time.
Wait Until Keyword Succeeds ${retry} ${retry-interval} Element Should Not Be Visible ${warning-overlay-div}
${retry} = the amount of time overall to perform the check
${retry-interval} = the time between each retry
Time Formats
(I would have made this just a comment but I cannot until I have 50rep - this is just something that might be worth trying)

automated testing ngx-datatable using robotframework with selenium

Has anyone used robotframework to test ngx-datatable? Since it isn't set up like a regular table, the selenium libraries Get Table Cell function doesn't work. Does anyone have an example of a work-around?
I've come up with a script that works for the time being.
*** Variables ***
${Table} = css=div[class^="datatable-row-center"]
*** Keywords ***
Get Value From Grid
#{RowNumber} 0 is the header
#{ColNumber} 0 is first column
[Arguments] ${RowNumber} ${ColNumber}
Sleep 3s
#{Table_Rows}= Get Webelements ${History_Table}
${Text}= Get Text #{Table_Rows}[${RowNumber}]
#{words} = Split String ${Text} \n
Log to Console #{words}[${ColNumber}]
[Return] #{words}[${ColNumber}]
This works as long as the class on the table rows remains 'datatable-row-center'

How to make multi-lines test setup or teardown in RobotFramework without creating new keyword?

I need to call two teardown keywords in test case but must not create new keyword for that.
I am interesting if there is a such syntax for keywords as for documentation or loops for example:
[Documentation] line1
... line2
... line3
Use the "Run Keywords" keyword.
From doc "This keyword is mainly useful in setups and teardowns when they need to take care of multiple actions and creating a new higher level user keyword would be an overkill"
Would look like that:
Test Case
[Teardown] Run Keywords Teardown 1 Teardown 2
or also
Test Case
[Teardown] Run Keywords Teardown 1
... Teardown 2
and with arguments
Test Case
[Teardown] Run Keywords Teardown 1 arg1 arg2
... AND Teardown 2 arg1
For executing multiple keywords in Test Teardown method use the following trick:
Firstly, define a new keyword containing the set of keywords you want to execute.
E.g. here Failed Case Handle is a new definition of the other two keywords take screenshot and close application. Consider this is to take a screenshot and then close the running application.
*** Keywords ***
Failed Case Handle
take screenshot
close application
Basically, when you call the Failed Case Handle keyword, take screenshot and close application will be executed respectively.
Then, in the ***Settings*** section define the Test Teardown procedure by the following example.
*** Settings ***
Test Teardown run keyword if test failed Failed Case Handle
or,
*** Settings ***
Test Teardown run keyword Failed Case Handle
So, in the first case Failed Case Handle keyword will be called if any test case fails. On the other-hand in the second case Failed Case Handle keyword will be called after each test cases.