I'm writing an automated test against a Salesforce site. I'm using Firefox version 21.0 and Selenium version 2.33.0.
During the test, I have a couple of alerts to deal with (with one "okay" button) and do so successfully. The alerts behaves normally.
Later in the test, in a table, there is a delete link. When it is clicked, an alert appears saying "Are you sure?" with two options, OK and Cancel. Clicking OK should delete that row in the table.
But when I run the automated test, after clicking on the link, the alert very quickly flashes on and then disappears. The row has not been deleted. It is there and has a blue background (as it does when the mouse is hovered over the row). The popup disappearing is nothing to do with the code that follows clicking the link, as I have tried putting a big sleep in between and it still happens.
I am running the test in Firefox, could it be an issue with firefox? I tried running it in Chrome instead, but then the test keeps failing at an earlier point because it cant find an element which firefox can.
Below is the method I run to handle alerts. But I don't think the problem is to do with this, because it happens before this code is run. This method runs immediately after the clicking of the link...
private void acceptAlert() {
String mainWindow = webdriver.getWindowHandle();
WebDriverWait wait = new WebDriverWait(webdriver, 20);
wait.until(ExpectedConditions.alertIsPresent());
Alert alert = webdriver.switchTo().alert();
alert.accept();
webdriver.switchTo().window(mainWindow);
}
Related
I have an application where a random popup message (NOT chrome popup message but a built in popup in the HTML) can suddenly appear.
If it appears, I cannot continue my test. I need to close the popup before I continue.
How can I make Cypress listen to these random DOM popups and close them automatically when they appear?
Cleanest way would be to change your application not to show the popup when it is running in Cypress mode. The best practice of detecting Cypress mode is checking if the Cypress object is exposed to the window or not.
// in your application code
if (window.Cypress) {
// logic that prevents the popup
}
Clipboard.js is working well in Chrome (v50.0), but won't copy text on Firefox (v46.0).
clipboard.on('error', function(e){...}) is being thrown, and clipboardjs is supported on v41+, but the error provides no information beyond providing which button was clicked to trigger the copy.
Any ideas what could be happening here or what I could check/try?
in the documentation it says that it's not supported in safari
Although copy/cut operations with execCommand aren't supported on
Safari yet (including mobile), it gracefully degrades because
Selection is supported.
That means you can show a tooltip saying Copied! when success event is
called and Press Ctrl+C to copy when error event is called because the
text is already selected.
For a live demonstration, open this site on Safari.
to get information about what was clicked check the trigger
clipboard.on('error', function(e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
I have a button which posts back through Ajax. I tried to find out what code executes when the button is clicked. I used Visual Event (screen capture below) to see how the event was bound but the info didn't help me enough. Then I set an event listener breakpoint on mouse clicks in Chrome. The breakpoint hit code in the main jQuery file which was also not helpful. So I blackboxed the file. Now when I click the button, no breakpoints are hit.
What's a systematic way to find the user code which gets executed? I also searched for 'live' and 'click' as text across the whole app. It was time consuming and didn't find where the click event for the button got attached. It's painful to do such a search. I would like to know the productive technique using Chrome's debugger or another tool. (Another browser's tips are OK)
Have you tried the Chrome profiler?
Launch the Chrome DevTools (F12)
Go to the Profiles panel
Ensure that Collect JavaScript CPU Profile is selected
Click Start
Perform your operation
Click Stop.
Then you should see a list of functions that were called.
There are several possible ways to do so. One is described by the user thesentiment. Another way is to use the DevTools' debugger.
Open the Chrome DevTools (F12)
Switch to the Sources panel
Click the Pause button () or hit F8
Perform your operation
=> The script execution will stop at the first line of the event handler function within jQuery. You can then step through to your actual event handling function.
Note that in Firebug this works much easier, because its Events side panel already displays the wrapped listeners, i.e. the functions that are called by a jQuery event listener:
I have a very large accounting system. In a user preferences section, the program has begun to act abnormally on my development machine only. No customers are reporting this, nor can I duplicate it on any of my other computers. Running Windows 8.1, others are on 7.0. Not exactly sure when this started happening because it's not the kind of thing one goes into on a regular basis. The preferences screen consists of a tab control and various standard controls. At the bottom is Okay, Cancel, and Apply buttons. All three buttons seem to be acting with the same strange behaviour. Clicking with a mouse does not generate a click event yet does not hang the system - mouseup follows and you can click it again and see the mousedown and mouseup but no click. However, since the Okay is defined as Default, pressing enter DOES create the desired click event, and all the code inside that even runs fine. Cancel and Okay also unload the form, but when clicked, that doesn't happen because none of the code gets executed, yet you can still navigate the screen (move between tabs and controls) but you can't even click the "X" button to close the form at that point.
Also, if you go straight in, and press enter, everything works and the form unloads, but if you do anything before pressing enter (or escape to cancel), like change a tab and/or edit a value, then press enter, the click event again does not run and the system semi-hangs.
I tried turning-off my anti-virus thinking that might have something to do with it, but no-go. Debugging is frustrating because while I finally got it execute the click event, the stop command inside that event (after debug.print "click") would allow stepping and success if just straight in and enter, but if anything else done as before described would stop at the stop statement (keyboard enter only still no mouse clicks under any scenario) and would do a total lock-out. In other lockouts where it would let me navigate, almost always selecting a new tab would cause a fatal error and it would force-unload VB for me, otherwise I had to use the task manager.
This is driving me nuts, but I don't know how else to debug it.
The culprit was tv_w32.dll which is Team Viewer. Turning-off Team Viewer allows my program to run normally.
I have a dijit dialog that pops up on clicking of a button. This dialog has a button which stands for submitting and one to hide the dialog On click of ok it sends a REST call and gets a response.
On error, an alert box is generated.
But what is happening here in IE 8 is that I need to explicitly again call a showdialog method to retain the dialog on screen.
What is expected behaviour is: when error occurs an alert box pops up and on click of ok the dialog in background retains. But this is not occuring normally. So I need to everytime check response and make an explicit call to show that dialog. If I do not call an explicit showdialog, the dialog simply visually seems nowhere(Gone!).
This is not a requirement if I use other browsers like chrome and FF which retain the dialog unless user himself cancels and hides them.
This explicit calling may not have been a problem unless it caused the blink effect. That is it has some delay and then shows( a sec or two after ok click on alert).
Further adding to the woe is that when this error scenario occurs and if user after clicking ok and then getting the dialog again after a blink follows and clicks cancel on dialog....poof! the behind screen that originally triggered that dialog still remains blurred! Hanging the browser!
Thanks & yes need a help, stuck on this!