3
votes

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.

5
Show us your Robot Code?Goralight
updated the question, please checkSarada Akurathi
Is there any implicit / explicit waits inplace? Just for debugging purposes place a Sleep | 2s just before that Click Element KeywordGoralight
I have placed sleep | 5s before and after the Click Element , it is not clicked the element in realSarada Akurathi
I don't exactly know why this isn't working. So I going to throw my debug steps at you! :D Is it a button? If it is a button have you tried Click Button?Goralight

5 Answers

3
votes

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
2
votes

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

0
votes

Similar problem was faced by me. The JavaScript worked perfectly.

Execute Javascript  document.querySelector('#HIRESearchTable > tbody > tr > td.searchLink > span').click();
0
votes

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();
0
votes

Sleep 1s after you found the element. It works for me.