Selenium waitForElementPresent hangs in IE11 - selenium

I'm trying to test a site with Selenium Grid via recordings from Selenium Builder. Everything seems to work for Firefox and Chrome on Windows and Mac, but I'm getting error messages when testing in Windows 7 + IE11.
Whenever I try to select or interact with an element I get:
Exception: Unable to find element on closed window
HTML element I'm waiting for is loaded after page load via jQuery and appears on page as:
<input id="email" name="username" type="email" autofocus="autofocus">
Selenium Builder Step waits for it to appear before continuing:
{
"locator": {
"type": "id",
"value": "email"
},
"type": "waitForElementPresent"
},
From various posts of people with similar problems I have done the following to try and rectify:
Made sure the security zones were all the same in IE 11
Made sure I wasn't using any "FLAKY" options anywhere (INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS)
Should I be accessing elements in a different way? Or is there an IE 11 setting I'm missing?

According to the Selenium IE guide (https://code.google.com/p/selenium/wiki/InternetExplorerDriver) IE 11 has a known problem where security zones can cause issues even when they are all set correctly.
The best option is to downgrade from IE 11 to IE 10 (How to downgrade from Internet Explorer 11 to Internet Explorer 10?)
This solved this issue.

A while ago noticed this strange behavior with IE(Cant remember which version), using Selenium and C#:
When an element is clicked for the second time, the whole thing freezes.
My fix was to keep track of all clicked elements in order to avoid repeated clicks.
This fixed some of the issues I was having with IE.
Hope it helps.

Related

window.stop() execution through selenium is not working

I am trying to read elements from the page using selenium but it seems the page is getting loaded infinitely. The element which I want to read is visible on the page (tried xpath and I was able to fetch the element). I tried the below code to execute the javascript command to stop the page load but for some reasons it is getting time out.
driver.executeScript("window.stop());
As #pcalkins suggested to use PageLoadStrategy, I used the "none" strategy in the chrome capabilities and it really did work. Below is the chrome capability property which I set.
"pageLoadStrategy" : none

autocomplete ignore by Edge 18 in blazor

I'm using autocomplete="off" for inputtext in blazor but its not working for Edge 18 version.
also trying autocomplete="anytext" but still its not working. both autocomplete="off" and autocomplete="anytext" are working fine for every browser.
Is there any other way to keep away autofill box from InputText?
On Edge 18 is only partially supported, read here : https://caniuse.com/?search=autocomplete
The only other possibility, I think, is to disable it from browser settings.

RobotFramework / Selenium Firefox: this-event not working?

I encountered a problem automating a test-procedure on my website. I there have a list of items and - to add a new one - a modal openes. Everything's fine til then - the RobotFramework fills out the checkboxes and inputs with text, but when it comes to the "Save"-button, Chrome and Firefox response differently.
Chrome does everything correct, closing the modal and saving the new item. Firefox on the other hand seems to click the button too, but nothing happens. The code "behind" the button is as follows:
<button id="submitSomething" type="submit" name="someName"
value="Save" onclick="window.wishlist.editPreSubmit(this, event)">Save</button>
Python 2.7.x (latest) 32 bit
wxPython 2.8 32 bit
geckodriver latest 64 bit
chromedriver 2.45
I tried somehing like:
Execute Javascript document.querySelector("#submitNew").click()
instead of
Click Button id=submitSomething
but without a change on Firefox sadly. Every tiny help would be greatly appreciated :)
Edit:
If I use
document.querySelector("#submitNew").click()
in the console of the browser which was opened from robotframework, it does not work either (firefox) and I get a warning:
form posted in windows-1252-codec, should be changed to utf-8
Br
To click the desired element you need to induce WebDriverWait for the element to be clickable and you can use either of the following solutions:
Wait Until Element Is Visible:
Wait Until Element Is Visible xpath=//button[#id='submitSomething' and #value='Save'][contains(., 'Save')] 20 seconds
Set Focus To Element xpath=//button[#id='submitSomething' and #value='Save'][contains(., 'Save')]
# invoke click
Wait Until Element Is Enabled:
Wait Until Element Is Enabled xpath=//button[#id='submitSomething' and #value='Save'][contains(., 'Save')] 20 seconds
Set Focus To Element xpath=//button[#id='submitSomething' and #value='Save'][contains(., 'Save')]
# invoke click

Unable to click button in mobile web in appium

After exhaustively searching for this over various forums, I still don't have an answer.
Here are complete details
I'm identifying the element through classname which points to multiple(4) buttons. I'm iterating through buttons and then search for text and when there is a match i click it.
This works fine with selenium webdriver and browsers such as firefox,chrome
Now I'm doing the same thing with appium.
Out of 4 buttons which are identified through classname, the script clicks 2 buttons successfully but for two buttons click happens(i can see the button being clicked) but new page which should be loaded is not loaded. The buttons for which click is not happening are in a footer class and other two are in div class.
Things i have already tried
Actions builder - click(), clickandhold()
Javascript executor
I'm currently trying with touch options, tap and by switching to native view but haven't found any success.
If any has encountered the same, a solution will be appreciated.
I want to avoid xPath because that might change in the page I'm working on, and I want to stress that the script is able to find the button, but is not able to click it properly.
You can filter your locator by using class name and index. Like this:
driver.findElementsByXPath("//*[#class='android.widget.ImageView' and #index='0']");
This xpath won't get change on other devices too.
Could you see: Unable to find an element in Browser of the Android emulator using Appium and C# ?
In case of testing web apps in browser the elements should be located as usual elements on the web page ( not as some classes like android.widget.EditText and android.widget.Button).
Upadting appium java client to 1.5.0 (from 1.3.0) solved the issue. Need to check why!

Selenium RC click command gets stuck

Solution:
Today (2011-04-13) handles Selenium RC the confirmation boxes under Firefox 4 badly.
I had to change back to Firefox 3.16 and then this problem disappears. Thanks again.
Original Question:
Hello Selenium gurus,
I am trying to execute an automated browser test from Java using Selenium 2.0b3 as the Java client and standalone server too.
The server starts a Firefox 4 with a specific profile.
The test is stuck at a "click" command; it waits and no timeout/exception/any error happens. During this click comes up a confirmation box, so I guess that is the problem, but I do not know why this gets stuck. In Selenium IDE comes not this confirmation box, only in RC.
The problem is not that, that the click does not happens (because the confirmation box appears), but that this confirmation box hangs.
I tried these but did not help:
selenium.click("css=div[id=command_Delete]");
selenium.click("id=command_Delete");
String JSscript = "jQuery('#command_Delete').click();" // See http://api.jquery.com/click/
selenium.runScript(JSscript);
These are just ways how to start the click.
Maybe I have to start a different Thread according these link: http://www.sqaforums.com/showflat.php?Cat=0&Number=567974&an=&page=0&vc=1
Thanks: Andras
Java code:
selenium.click("//div[#id='command_Delete']/span");
//stucks here
//so this is not reached:
String confirmation = selenium.getConfirmation();
HTML:
<div id="command_Delete" class="...">
<div>...</div>
<span>Delete</span>
<div>...</div>
<br><br>
</div>
Javascript:
<script type="text/javascript">
$('command_Delete').addEvent('click',function(){
var isConfirmTrue = confirm('Do you want to delete?');
if (isConfirmTrue) {
var myForm = getFormObj(document, "deleteForm");
submitForm(myForm);
}
});
</script>
And in the Java, it hangs waiting the selenium rc to answer:
HttpURLConnection.getInputStream() line: 912 [local variables unavailable]
HttpURLConnection(HttpURLConnection).getResponseCode() line: 367 [local variables unavailable]
HttpCommandProcessor.getResponseCode(HttpURLConnection) line: 147
HttpCommandProcessor.getCommandResponseAsString(String) line: 167
HttpCommandProcessor.executeCommandOnServlet(String) line: 107
HttpCommandProcessor.doCommand(String, String[]) line: 89
DefaultSelenium.click(String) line: 167
...
Have you tried replacing
selenium.click("//div[#id='command_Delete']/span");
with
selenium.click("id=command_Delete");
?
It seems to me that since the event is binded to the div itself that should work.
Additionally, you can execute the click action directly by doing this, I'm using jQuery since you seem to already have it loaded on the page and it makes things easier (especially for cross-browser testing):
String JSscript = "jQuery('#command_Delete').click();" // See http://api.jquery.com/click/
selenium.runScript(JSscript);
You'd just need to evaluate if this solution is good for you.
If a confirmation box is popping up the test will block until that confirmation box has been removed. You can do a quick manual test to see if this is your problem.
Run your test and when the confirmation box comes up manuall y interact with it, if everything else is fine the test should continue from that point as per normal.
Selenium is waiting for the page to load, but the pop up box is blocking the page from loading which is eventually resulting in a timeout.
You can try and work around this using selenium.chooseOkOnNextConfirmation(); before your click.
Are you sure your widget can afford a click?
I would try the CSS identifier:
selenium.click("css=div[id=command_Delete]");