Reputation: 123
I am trying to create a automation framework with nunit + Selenium + c#
Our webadmin is based on Devexpress framework hence I can't click button by it's "ID" or atleast I dont know how to. The subtitute to this is simply pressing "Enter" button. I have already tried
driver.FindElement(By.XPath("String")).SendKeys(Keys.Enter);
Upvotes: 7
Views: 36427
Reputation: 2311
Use below code to click on an invisible button.
IWebElement tmpElement = Driver.FindElement(By.Id("invisibleButton"));
var executor = (IJavaScriptExecutor)Driver;
executor.ExecuteScript("arguments[0].click();", tmpElement);
wait.Until(d => { return d.Title.Equals("pageTitle"); });
Upvotes: 1
Reputation: 71
using OpenQA.Selenium.Interactions;
Actions builder = new Actions(driver);
builder.SendKeys(Keys.Enter);
For more information: Typing Enter/Return key in Selenium
Upvotes: 7
Reputation: 1525
RON, there is a possibility that DOM is taking time to load after the GoToUrl call. Increase the implicit wait time so that findElement waits more time before throwing any exception. Or use explicit wiat --- http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp
If still this doesnt work then use Actions class -- http://www.guru99.com/keyboard-mouse-events-files-webdriver.html
Upvotes: 0