Reputation: 23
I am using RobotFramework (RF) to test a web app. I want to click a button within a popout. I have tried xpath and javascript to find the element. SeleniumLibrary says that that element has been clicked, but on the frontend UI side, I can't see that the button is actually clicked because the event is expected to display selection of items. What the script result says is not sync to what shows in the UI. Manual click works fine.
Here are the js and xpath codes I tried...
Execute Javascript
document.querySelector("#CallOutcomes_InboundInbound_menuPlace").querySelector('.hierarchicalMenuButton').click()
Execute Javascript
document.querySelector("#CallOutcomes_InboundInbound_menuPlace").querySelectorAll('span[style="height: 0px;"]')[0].querySelector("#startMenuButton").click()
Execute Javascript
document.querySelector("#CallOutcomes_InboundInbound_menuPlace").querySelectorAll('span[style="height: 0px;"]')[0].querySelector('.hierarchicalMenuButton').click()
Click Element //*[@id="CallOutcomes_InboundInbound_menuPlace"]//*[contains(@class,"hierarchicalMenuButton")]
Here is the html snippet...
<pre class="showQueryMenuTable" id="CallOutcomes_InboundInbound_menuPlace">
<span style="height: 0px;">
<input type="button" class="hierarchicalMenuButton" value="Call Outcomes" id="startMenuButton">
When I try the javascript code in the console, the locator is able to find the element but when .click() is added, that's when things go array: the button is not being clicked.
Is there anything special I need to do here? It works fine with other buttons/elements. What am I missing?
----- Edited 10 Jan 2020 ----
I've discovered that the event for the button is a mouse down, not click. Surprisingly, the RF's Mouse Down keyword does not work. So I figured I'd used Javascript's instead.
Execute javascript document.querySelector("#CallOutcomes_InboundInbound_menuPlace .hierarchicalMenuButton").dispatchEvent(new MouseEvent('mousedown',{}));
That command fixed it. I am not sure what the long term effect of this to my script but it works in the interim. Cheers!
Upvotes: 1
Views: 352
Reputation: 23
I've discovered that the event for the button is a mouse down, not click. Surprisingly, the RF's Mouse Down keyword does not work. So I figured I'd used Javascript's instead.
Execute javascript document.querySelector("#CallOutcomes_InboundInbound_menuPlace .hierarchicalMenuButton").dispatchEvent(new MouseEvent('mousedown',{}));
That command fixed it. I am not sure what the long term effect of this to my script but it works in the interim. Cheers!
Upvotes: 0