(Using Selenium Webdriver / Java / Eclipse / TestNG)
I'm testing an application that when you click on an item in a table row, a menu of actions popsup. It disappears if you move the cursor away from it. I can go as far as getting the menu items text and title, but can't click on them.
There's a user_plans.js script that's triggered when I click on a menu item. Next is the pertinent html code and javascript.
RELEVANT HTML CODE
----------------------------------
<td id="yui-gen1000084" class="yui-dt1000000-col-actions yui-dt-col-actions" headers="yui-dt1000000-th-actions ">
<div id="yui-gen1000083" class="yui-dt-liner">
<div id="yui-gen1000086" class="pm-dropdown large_label" data-label="Actions" data-context-data="9802">
<div id="yui-gen1000085" class="pm-selected-item-wrapper">
<div id="yui-gen1000087" class="pm-selected-item" data-value="" style="max-width:135px;height:15px;line-height:15px;" title="Actions">Actions</div>
</div>
<ul>
<li class="" data-event-name="action:edit" data-value="" title="Edit Properties...">Edit Properties...</li>
... (more 'li' items go here)
</ul>
</div>
</div>
</td>
<td class="yui-dt1000000-col-shim yui-dt-col-shim yui-dt-last" headers="yui-dt1000000-th-shim ">
...
This is how I describe the element and get the title:
@FindBy(xpath=".//div[contains(@class,'pm-dropdown large_label')]/ul/li")
private List<WebElement> actionsList;
String menuItem = actionsList.get(0).getAttribute("title");
RELEVANT JAVASCRIPT
-----------------------------------
" YUI.add('u_plans', function (Y) {
Y.on('action:edit', function(value, dropdown_info){
var usst_id = dropdown_info.context_data;
u_plans.editPlan(usst_id);
});
...
* "GLOBAL" variables
...
u_plans.editPlan = function(usst_id) {
Y.fire('edit_plan:edit_plan', {usst_id: usst_id, datatable:u_plans.datatable});
return;
};
...(There are 650 lines of code in this script)
});
SOLUTION???
---------------------
Here's what I would like but don't know how to do it:
((JavascriptExecutor) driver).executeScript(user_studies.js, element);
If the above is possible, where in my test would I run this? Would it be instead of actionsList.get(0).click(), that doesn't work due to the javascript?
Here's what wouldn't work:
String code = "[all 650 lines of javascript code in user_plans.js here]";
((JavascriptExecutor) driver).executeScript(code, element);
Thanks.