Reputation: 1188
Click Element
is not working in Robot Framework, in the log.html it shows that it clicked on element, but it does not actually happen on the browser
This application is not an Angular JS application.
I have tried the same functionality in other application which is an Angular JS, it worked fine.
My Robot code is as below:
*** Settings ***
Library Selenium2Library
*** TestCases ***
Login to Application
Open Browser ${url} ff
Maximize Browser Window
Select from List by value id=selectedCountry MU
Input Text id=userid rajaint
Input Password id=password rajaint1
Click Element id=Submit1
what can be the reason for this?
I'm stuck in automation, as I stopped at the login.
I cannot share the application url as it is confidential.
Upvotes: 3
Views: 21651
Reputation: 1
I have used Sleep function before clicking on element " Sleep 10seconds".Its worked for me in Edge.
*** Test Cases ***
Login
Open Browser ${url} ${browser}
Maximize Browser Window
Set Selenium Implicit Wait 10seconds
Input Text name:uname anbu
Set Selenium Implicit Wait 10seconds
Wait Until Element Is Visible xpath://input[@id="submitButton"]
Wait Until Element Is Enabled xpath://input[@id="submitButton"]
Sleep 10seconds
Click Element xpath://input[@id="submitButton"]
Set Selenium Implicit Wait 10seconds
Input Text name:uPwd Tatanexon@2023
Set Selenium Implicit Wait 10seconds
Sleep 10seconds
Click Element id:submitButton
Upvotes: 0
Reputation: 1559
For this kind of scenarios, you can use JavaScript Executor
. But in most of these cases, you can't find the Id of the element. So I have implemented a common keyword which can be used with the xpath.
Click Element By JavaScript Executor [Arguments] ${elementXpathLocator} ${retryScale}
[Documentation]
... Click an element by xpath using javascript executor ...
Wait Until Keyword Succeeds 2x 1 s Wait Until Element Is Enabled ${elementXpathLocator}
Execute JavaScript document.evaluate("${elementXpathLocator}", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0).click();
Upvotes: 0
Reputation: 1135
Similar problem was faced by me. The JavaScript worked perfectly.
Execute Javascript document.querySelector('#HIRESearchTable > tbody > tr > td.searchLink > span').click();
Upvotes: 0
Reputation: 21
I have experienced the same problem but the Press Key Trick is not working. I used this hack instead
Execute JavaScript
document.getElementById('Submit1').click()
And it's working fine
Upvotes: 2
Reputation: 2107
After having a chat with Sarada - We discovered that the issue was on his application. The problem was the application had to lose focus of the drop down menu and the username field in order for the validation to pass through - and allowing more input from robot.
After some trail and error, we figured out how to lose focus of an element and allow the validation to work as intended; which in return meant everything else worked smoothly!
I suggested Focus
but that did not work so instead we forced it using:
Press Key id=userid \\9
Which sends a Tab to the browser. Making it lose focus and making the validation tick over!
In the end the Robot File looks like:
Open Browser ${url} ff
Maximize Browser Window
Wait Until Element Is Visible id=selectedCountry 10s
Click Element id=selectedCountry
Select from List by value id=selectedCountry MU
Click Element id=selectedCountry
sleep 2s
Focus id=userid
Click Element id=userid
Input Text id=userid rajaint
Press Key id=userid \\9
sleep 5s
Input Password id=password rajaint1
sleep 2s
Click Button id=Submit1
sleep 10s
Capture Page Screenshot
Upvotes: 3