I'm using this code to click on an element: #driver.find_element(:id, "test").click and it works well when I run script on FF16 with Selenium Ruby Webdriver (selenium-webdriver-2.26.0.gem).
However, when trying to run script in IE9 browser (using IE driver: IEDriverServer.exe), no error occurs, but Click event does not work, Selenium seems to ignore this line of code and go to next lines of code.
Note that this issue does NOT happen when I tried to click on many other elements on my application (ex: button, link), it only happens with some elements I want to click.
Please help guide me how to resolve for Selenium to fire Click in IE9 browser. Thanks much.
Try click using JavaScriptExecutor or Click after moving to the element. refer below C# code
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].fireEvent('onclick');", element);
or
Actions action = new Actions(driver);
action.MoveToElement(element).Click().Build().Perform();
where element is IWebElement instance of element to click
Related
I have selenium test running in a remote server in headless mode using chrome driver. Following step tries to click on a button but the button doesn't get clicked.
Below test step tries to click the element:
action.moveToElement(element).click().build().perform();
Here is the html of the button:
<button class="icon-btn" data-uk-tooltip="" data-ember-action="90"><i class="us -icon-hover us-icon-plus-circle"></i></button>
Any insight why in headless mode the button is not clicked by above test step? would appreciate any ideas.
Let's try with this, it will work :
WebDriver driver = new HtmlUnitDriver();
((HtmlUnitDriver) driver).setJavascriptEnabled(true);
I suspect this to be an actual Selenium issue. But I manage to solve and stabilize my tests. See Using Selenium, is there another, more reliable, way to use click command on an element in Headless Chrome?
I am using the Selenium plugin to test my javascript code. Part of my code is that, onclick anywhere on the document body, a div is created and placed there. It works fine when I click myself, but after the click action on a selenium test case, nothing is created and I'm left with an error. Is this some missing feature of selenium, or am I doing something wrong?
Here is a screenshot:
I open a page and ask selenium to click on a button that is placed at the bottom of this page. The button is not displayed on the current screen (so you have to scroll down to see it). As I know selenium have to scroll to an element automatically when I use Click() method.
Unfortunately when I perform Click() method it only scrolls to the element without clicking on it.
When I make a breakpoint before clicking on the element and scroll to it manually then it clicks on the element well.
I have Selenium Webdriver C# v. 2.48.2
I use ChromeDriver v. 47.0.2526.106 m
It seems to me that this problem has been present in the previous versions (so, for a long time) but some versions ago I could use "Scroll to element" method that solved this problem. Now the method I used doesn't work.
The method was the following:
((IJavaScriptExecutor)Driver).ExecuteScript("arguments[0].scrollIntoView();", webElement);
Try to use Actions to scroll
Actions action = new Actions(driver);
action.MoveToElement(elementToClick).Build().Perform();
elementToClick.Click();
Android and iOS browsers handle the click event differently.
Say for example, an onclick event handler is attached to an element. When it is clicked for the first time it works fine, but when the same element is clicked again, it's not working. If we click some other element and then click on the previous element it works.
Is there any workaround to solve this issue so that if the same element is clicked again will work perfectly ??
The question is not clear. Please post some code to explain the problem.
For android if you are talking about onclick in a webview then you should check if you have enabled Javascript.
webview.getSettings().setJavaScriptEnabled(true);
Apologies for posting this as answer as I don't have 50 rep points for commenting.
I'm using selenium IDE (currently available only on firefox) to do some automated testing of a site I'm coding. When selenium navigates to, a form filling page, and fills in the info - a 'window.alert()' is called by a button.
When using selenium my set of commands look like this:
open /
clickAndWait document.form1.Action[1]
select stuff
type stuff
etc, etc
click name=myPreview
When I click through recording this the first time, it works no problem. When I rerun the script window.alert and alert don't work from the console or anything. I've debugged it, and its not working.
When a window.alert() is called as part of a selenium script (I'm talking at least in the IDE), it is called even though a user watching does not see an alert pop up. According to the documentation:
Under Selenium, JavaScript alerts will NOT pop up a visible alert
dialog.
Selenium does NOT support JavaScript alerts that are generated in a
page's onload() event handler. In this case a visible dialog WILL be
generated and Selenium will hang until someone manually clicks OK.
Both assertAlert and verifyAlert are both based off getAlert(), all of which do the alert 'stuff' in the background. So try adding these functions to ensure that the alert is working, run the script, and then check to see if it works.
A note: this only works if you ensure the test fails before you put in the alert (basic idea of testing, fail first - make test pass).