Click button with oncick javascript not working in Selenium IDE - selenium

I have two buttons that are linked to a onclick javascript (see below)
<button
type="button"
class="ui-datepicker-current ui-state-default ui-priority-primary ui-corner-all"
onclick="DP_jQuery_1480511128847.datepicker._gotoToday('#historical-datepicker');"
>Current Month</button>
<button
type="button"
class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all"
onclick="DP_jQuery_1480511128847.datepicker._hideDatepicker();"
>DONE</button>
Clicking on DONE should update the page with new content. It does work normally but not with selenium IDE test.
Selenium find the correct button but it does not trigger the load of the new page.
All locators work when I click on Find: (see locators) :
xpath=(//button[#type='button'])[3]
//div[#id='ui-datepicker-div']/div[2]/button[2]
//button[2]
The div which contains the button is hidden at the start of the page. It is displayed by clicking on a field in the page.
Any ideas why the page does not load with selenium IDE?
Another thing, when I play the selenium IDE test, there is no error reported. And if I manually click in any part of the page, the new page loads.

Related

File upload filename text overflows only during Selenium Webdriver session, blocking the upload button

During testing with Selenium + Chrome + Webdriver the filename chosen in a file input field overlaps the edge of the field, and covers the upload button so it cannot be clicked on.
The error I get in testing is valid and correct, as I cannot click on the button manually either:
Exception in thread "main" org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <button type="submit" id="article-file-upload-submit" class="ui primary button">...</button> is not clickable at point (427, 451). Other element would receive the click: <input type="file" name="import" id="article-file-upload-file" class="ui button" required="" data-qa-tag="project-file-import">
Why would viewing a page in a webdriver session change the rendering of a field?
This is what it normally looks like in Chrome:
This is what it looks like during testing in Chrome via webdriver:
(they are the same size in real life)
I am loading the same page here, in the same browser version, logged in as the same user, inside the same project and uploading the same file. The only difference I can see is the "bad one" is launched from Java, Selenium, Webdriver, from a VS Code project. So it is a different process.
Chrome Version 86.0.4240.80 (Official Build) (x86_64)
chromedriver v86
Mac OSX
The browser window isn't any narrower, (responsiveness doesn't affect this element).
I'm using the latest Semantic UI v2, the field is inside an accordion inside a segment, but in 2 years of dev evolution, I've never seen this overflow problem.
<div class="ui input">
<input type="file" name="import" id="article-file-upload-file" class="ui button" required>
</div>
<button type="submit" id="article-file-upload-submit" class="ui primary button">
<i class="icon upload"></i> UPLOAD
</button>
Click using javascript should work:
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
String script = "document.getElementById('article-file-upload-submit').click();";
javascriptExecutor.executeScript(script);
It turned out that the overlap issue was just a CSS bug in my latest app version, but for some reason it only showed up in the new web driver Chrome session.
A while later it showed up in the other Chrome window, so it was probably just a CSS caching issue. I've not seen this before though, as I am using a automated Gulp build with Browsersync which normally keeps everything up to date.
So it's nothing to do with webdriver, and in fact the test was finding a true bug, so it's good that it failed!

Click hidden element using selenium webdriver

I need to click on the fields bug, epic, feature, issue and task which appear on click the "+" icon.
I inspect each of the elements and the see the same common xpath highlighted in the image in developer tool.
How do i find the xpath of each of the elements highlighted and click on them using selenium webdriver?
<body class="lwp">
<noscript><div class="absolute-fill flex-column flex-center"><h2>JavaScript is Disabled</h2><p>Please enable javascript and refresh the page</p></div></noscript>
<input type="hidden" name="__RequestVerificationToken" value="t6WnlqRwnH3QtDIOt2b3JiHWYI1V5vB3MheOCOTH7Fx6QaBNoXWz4k8P4luP9i7TYw70KVq4O2vuwa8DQRuLcdUxo_KKVjcmxorJTHAE3c42sdjYqojLZkOSNt1gad70mD0BBA2" />
<div data-componentregion="page" class="full-size"></div>
<div class="bolt-portal-host absolute-fill no-events scroll-hidden"></div>
</body>
You need to handle windows here because when you click "+" new window appearing with elements "bug","epic","feature",,,etc
should be parent window and "epic",,,, are child window
I could not identify unique xpath for the elements as all the elements had same xpath. using sikulix library solved my problem

Click on element in robot framework is not working in ie and work fine in chrome and fiorefox

Click Element is not working in Robot Framework, in the log.html it shows that it clicked on the element, but it does not actually happen in the browser.
The element which I want to click is:
<a href="http://www.twitter.com/intent/tweet?text=Orange%20named%20a%20Top%20Employer%20Global%202018%20for%203rd%20consecutive%20year&url=http%3A%2F%2Fintegration-ruby.proj.620nm.com%2Fen%2Fblogs%2Forange-named-top-employer-global-2018-3rd-consecutive-year&via=orangebusiness" class="share-button-twitter" target="_blank" title="Share on twitter">
<span class="fa-lg fa-stack text_black"> <i class="fa fa-circle-thin fa-stack-2x"></i> <i class="fa fa-twitter fa-stack-1x"></i> </span>
</a>
I run my test using:
Execute JavaScript document.querySelector(".share-button-twitter").click()
Execute JavaScript document.querySelector('a[title="Share on twitter"]').click()
Execute JavaScript document.querySelector(".fa-lg fa-stack text_black").click()
Click Link //a[#title="Share on twitter"]
Click Element //i[#class="fa fa-twitter fa-stack-1x"]
Click Element //span[#class="fa-lg fa-stack text_black"]
The element is visible in the page, and the script works fine in Chrome and Firefox I find this issue with the browser IE.
What can be the reason for this? Any idea to solve the problem?
Update your Internet Explorer to the latest version. And also download the appropriate supported version of IEDriver for that version of IE. The problem is only here, and no where else.

Failed click using Selenium and XPath

For test automation on a web app I am currently using Robot framework and the Selenium library. There comes the moment I want to click on a button and then I wait for an element to appear. Alas, the click, although recorded successful in the log, does not lead to the apparition of the element I wish. In fact it is as if the click never happened.
To click on the button, I retrieve it using xpath. Using Firepath I successfully verified that the element is unique and does exist but what it shows leads me to think I have found why the button is not clicked correctly
You can see in light blue the button I want to click on and wrapped with dotted line the zone detected by firepath.
Is it possible that the click is done next to the button instead on it ?
Here is the incriminated line :
Click Element xpath=(.//button[contains(#id,'editContract')])[1
Edit :
HTML of the page :
<button id="listContractTableForm:listContractTable:0:editContract" name="listContractTableForm:listContractTable:0:editContract" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only" onclick="window.location.href='destinationPage?faces-redirect=true&contractEntityContractId=678'">
<span class="ui-button-icon-left ui-icon ui-c ui-icon-search"></span>
<span class="ui-button-text ui-c">ui-button</span>
</button>
Assuming you want the span with class containing ui-button-icon-left ui-icon ui-c ui-icon-search
//button[contains(#id,'listContractTableForm')]/span[contains(#class,'ui-icon-search')]
if you want the span with class="ui-button-text ui-c" simply change the class in the xpath

When and how to use switchTo() method in webDriver (Selenium 2) to handle window/pop up

I am having trouble clicking or interacting with some page elements. They seem like normal DOM objects. just buttons here is the code for one
<div style="clear: both; text-align: right">
<img id="nextstep" class="nextbtn" height="21" alt="" src="/edit/images/author/next.png">
</div>
After clicking a button as "Upload file" another pop up window was opened. My task is to upload a file at pop up window and back to original window. I'll try to explain
I start a webDriver for
www.test.com (<- made up name for example)
I login
click upload a file button
After this click our site redirects to www.foo.com instead of the above I am using the same driver created earlier and I try to interact with the buttons on the post upload page
button.click()
It never finds these buttons but they are there in firebug and appear normal.
You may try to switch to the window again after the redirect.
Save you window handle:
String myWindowHandle = driver.getWindowHandle();
redirect to the page you want and then call switchTo using the window handle:
driver.switchTo().window(myWindowHandle );
Does your page contain any frames? It may also be possible that you are not in the correct frame after the redirect.