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).
Related
i wanted to ask if there are web elements blocked by default? If yes is it possible to not block them anymore?
Im running a cypress test and after clicking a save button there has to be a messagebox(similar to an alert).
This messagebox is not showing up after clicking the button.
Did anyone have similiar experiences?
Some infos :
Browser used : Edge
messagebox has the div tag
messagebox is nested inside of an iframe
I tried to run the test with the minium amount of code to verify if not some kind of comparision blocked me. But thats not the case.
I also tried a cy.wait for a longer time to see if it loads up.
I also tried a cy.reload but still nothing.
When i do it manually on Edge everything is working fine. The messagebox is showing up after clicking the save button but when cypress runs the test it just isnt showing up.
When i click on the button manually inside the cypress testrunner it´s also NOT showing up.
I am getting a print screen option on clicking a button. I made no changes to the js or HTML file of my webpage to change the onclick() behavior for the botton, I wrote some kind of a print command in the chrome debugger console and since then the pop-up is coming. I don't exactly remember the command. How do I undo this change? On pushing the code to GitHub, this behavior was repeated in the production environment.
Using Java, selenium and xpaths. I am verifying a Citrix project. Really all I have to do is login, show the favorites and apps buttons and that they are there. I get this window, which blocks everything:
And I can't do Selenium clicks until it is closed. Problem is, inspect does not show it, there is not a new windowhandle to locate it, and trying to find any xpaths does not work.
I can continue by using javascript clicks to click items blocked by this view, but it gets annoying and they may not accept it.
Before you suggest it, we are not allowed to use Robot. I looked for a Javascriptexecutor to just hit "ENTER" (since manually you can hit ENTER to download it) but couldn't find one. Uasing Actions(driver) does not work either because I think the window is not recognized.
There is a link "already installed" which I can click (with javascriptexecutor) and continue, but the popup window stays visible. Perhaps use Javascriptexecutor to open a link in a new window? But I tried some things which didn't work, although perhaps I did not have the right idea.
Any suggestions? BTW another solution that won't work is to do it manually the first time, because no matter how many times it runs and how many times the download button was clicked manually, the next time it comes up I get the window again.
Any ideas? (I scribbled out personal company info). Oh, and it is not an Alert. At least none recognized.
I am building a UI testing framework which uses a headless browser (phantomJS in my case) to interact with html documents - without using jQuery I need to display a prompt (which is fine) and then programmatically enter text into the prompt dialog and then click OK, all with pure javascript. This will then add some text to a div so that I can verify the result.
Everything I have read online seems to suggest that this is not possible as the prompt/dialog boxes are built-in to the browser itself and not part of the DOM. I cannot see any properties/methods on the DOM to get the dialog and document.activeElement is returning me back the page, not the prompt. So I'm stumped.
How do I do this?
Alert & prompt are not part of DOM, they are part of browser. You can't simulate their invoke behavior from your code.
I think you need an external program (i.e. a program that runs besides the browser) which can detect prompt windows from the browser, and then fill them with text and submit them. I suggest you start with programs that can simulate key strokes like this user asked.
Is there a way I can set up javascripting in Chrome's console so that it does not process my statement as soon as I hit return. If I'm trying to test something out by just writing some javascript there, it processes before I'm done writing.
//here I am writing in the console
if ($(el).size() === 0){
//now I hit return because I want to type some stuff if this evaluates to true
//but return submits it as a finished piece of javascript and of course
//I get SyntaxError: Unexpected end of input before I can have a chance
//to finish the logic
I know I can hit shift+return and get a line break, and though that's a small inconvenience, it's still a bit of an inconvenience. Is there anyway I can tell it to hold off processing until I hit a macro like shift+return?
It's the same way in Firebug. Maybe there's an option there. Or maybe someone knows of a good third party add-on. Thanks.
In the comments I posted the ticket for the request for support, but it has been there for awhile. Chrome does have snipplets, but you have to enable them.
In the address bar type about:flags
Enable Developer Tools experiments
Restart the browser
Open the Developer Tools open the settings menu [gear on bottom right corner]
Click the Experiments tab [on left], check Snippets support
Restart the browser
In the Scripts panel, there will be a Snippets tab, click on it.
Right click on the area below and from context menu select New
You can than Edit and Run the code like a file. Run it with the context menu or play button.
A multi-line console effectively lets you do what you want. Chrome has a request for this but is otherwise not really available.
Firebug Lite for Chrome does allow it. Just click the little red button at the bottom-right of the Javascript console.