I am using Selenium WebDriver in C#. I have a RadMenu in which I want to hover over, once I do it; it should expand a sub menu that has a particular webelement i want to click. I am having to use JavaScript to click the element but that doesn't seem to expand the menu, are there any java script commands I can use to do this. For example:
IJavaScriptExecutor js = ts.getDriver() as IJavaScriptExecutor;
js.ExecuteScript("arguments[0].style.display='block'",leftPane_Customer);
js.ExecuteScript("arguments[0].click()", leftPane_Customer);
js.ExecuteScript("arguments[0].scrollIntoView(true);",leftPane_Customer);
the .click() seems to highlight the first menu but that is as far as I can get. Can anyone offer a solution (javascript syntax included) to expand the submenu?
Thanks
You can simulate hover event using method as follows
However click event on dynamically toggled element could cause a lot of troubles. To get very stable simulation of click event I use the following code
This code is a part of Maintainable Selenium project. You can review project site to get more info about creating maintainable UI tests with Selenium https://github.com/cezarypiatek/MaintainableSelenium/