I am working on testing a add on on MS Word using Coded UI tests in Visual Studio. I am at a point where I need to verify that after signing in, the user sees a new pop up window. I am not sure how to verify this. I try dragging the cross hair icon over on the pop up window, but am not sure which assertion to add.
If you drag the assertion tool over the entire Window, you can do an assertion over one or all of the following:
Control Type - this will ensure that your 'webpage dialog' is a 'window'
Exists - this will check that your 'webpage dialog' exists and has indeed poped up. This is good for creating a negative test too (e.g. testing a scenario where the window should not popup if the user does not sign in correctly)
Title - if you know what the title of your popup is, you can test that too
Related
I'm using Selenium for integration testing of our web app, and it's been working great up until I got far enough down the sidebar menu. Suddently the Create test would fail with org.openqa.selenium.ElementClickInterceptedException: element click intercepted. Other element would receive the click:
The error was very sporadic - order of tests would affect which test class failed - but finally I figured out the reason is that the tooltip from the most recently clicked menu option covers the button I'm trying to click. Not really sure why sending input to form elements (using WebElement:sendKeys() and org.openqa.selenium.support.ui.Select) does not count as moving the mouse away.
Is there a way to make Selenium work around this, or do we have to turn off tooltips in the test version (for obvious reasons I don't like the idea of running our tests on a custom version of the web app)?
I'm trying to test a Java FX application within IntelliJ and I'm using TestFX however I'm unsure how to test whether a window opens when a button on the interface is clicked. I've tried making a getter to get the primary stage, then assertingTrue that this opens - however this isn't the stage that should appear on the button click anyway.
Any advice/help?
Thanks.
If you just want the test whether the spawned Window is showing the this should do it (using the Hamcrest matchers):
FxAssert.verifyThat(window("My Window"), WindowMatchers.isShowing());
If you want to actually further interact with or test that window then you should try using the one of the targetWindow(...) methods of FXRobot (from which ApplicationTest and ApplicationRule derive). There are server overloads, but the simplest one is where you supply the title of your window:
https://testfx.github.io/TestFX/docs/javadoc/testfx-core/javadoc/org.testfx/org/testfx/api/FxRobot.html#targetWindow(java.lang.String)
This will give you an FXRobot instance for that window's scene to allow you to perform further testing.
Note: this answer refers to TestFX 4.
I am writing a test that verifies that a warning to the user before the user opens a document. If the user says that they still would like to open the document, the document opens in an external application (pdf or word).
But now I have an external application over the browser window, and it messes up for other tests.
So, what are the best practices around this kind of issue? Rewrite of the appliction to allow for not opening documents in test?
Added description:
The problem is twofold.
1) It starts processes (word and acrobat) that fills the desctop and requires resources from the test-slave
2) The external process seems to interfer with other tests since (guessing here) it is located over the browser window.
what i understood from your post is, the document(word/pdf) is opening in the browser window hence you are not able to proceed with further steps. If so, you can verify the Title to make sure the document is opened in browser window and can navigate back using below snippet.
driver.navigate().back();
Hope this helps.
What I understand from the line
'But now I have an external application over the browser window, and it messes up for other tests.'
is that once user clicks on open button a new window opens up (Window based application) since you have mentioned PDF or Word.
You can use robot class in such cases, below code snippet will close the current active window:
Robot rbt = new Robot();
rbt.keyPress(KeyEvent.VK_ALT);
rbt.keyPress(KeyEvent.VK_F4);
rbt.keyRelease(KeyEvent.VK_ALT);
rbt.keyRelease(KeyEvent.VK_F4);
Make sure you deal with sync issues properly so that intended window is closed instead of AUT.
I'm exploring Robot Framework for some smoke testing of a site, and at a point have to sign in, which opens a new window. Moving to the new window with Select Window works for me, but I'm bridging this change by identifying the title of Sign In, and the new window does not immediately adopt that title as it loads your login form - sometimes this takes half a second, sometimes more than 5.
I'm working around this right now by having the test sleep for the obnoxiously long period of 10s, but surely there are more reliable ways of ensuring that I can change my target window to the new one, and not have my test fail and exit while the page is loading. I took a shot at using the redirect url as the identifier, but sometimes it redirects very quickly and fails, or if not, then it gets hung up on the next check for the login field that isn't loaded. I've seen commands like Wait Until Element Is Visible, but unfortunately that doesn't help when I can't target the window where things are loading...
For the sake of it:
*** Test Cases ***
Basic Workflow
Open Browser To Homepage
Go To Sign In
*** Keywords ***
Open Browser To Homepage
Open Browser ${HOMEPAGE} ${BROWSER}
Maximize Browser Window
Set Selenium Speed ${DELAY}
Go To Sign In
Click Button Sign In
Sleep 10s
Select Window Sign In
Title Should Be Sign In
Using Selenium2Library currently.
lauda had it right in writing out a Keyword for managing the Select Window. I found Wait Until Keyword Succeeds and made a keyword for it to wait on.
Go To Sign In
Click Button Sign In
Wait Until Keyword Succeeds 20s 3s Switch To Sign In Page
Title Should Be Sign In
Switch to Sign In Page
Select Window Sign In
Thank you, both!
In order to automate DOH tests during our build process, I use Selenium RC to launch different browsers (IE and Firefox) on a server placed on a different domain than the build machine. Each browser is directed to our runTests.html in order to start DOH.
Sometimes, when a test that uses doh.robot starts, the following message is shown:
"DOH has detected that the current web page is attempting to access DOH, but belongs to a different domain than the one you agreed to let DOH automate. If you did not intend to start a new DOH test by visiting this Web page, press Cancel now and leave the Web page"
but since these tests are unattended it just sits there waiting for someone to click OK, and Selenium times out (in IE 8 it seems like the pop-up disappears automatically but the robot does nothing afterward).
As I said, it doesn't always happen. After you click OK on the Pop-up, the message will stop showing, and the message can go away for several sessions, but then it will show again in which seems to be an arbitrary way.
Does anyone knows a way to prevent this pop-up from showing?
This is probably not the correct way to do it, but in util/doh/robot/DOHRobot.java, you may be able to modify the code to not check that or always simulate pressing "OK". I haven't tried it myself, but I may also need to do that for some of our automated testing.
When the DOH robot is initialized, it first tries to click in the upper left corner of the page you are trying to test. If you obscure this div (you can see it with firebug), then the message will pop up. I think the problem is that your page isn't always loading up quick enough.
It is somewhat of a challenge to fix this. I haven't used DOH in awhile, but I don't think there is any way you can use a setTimeout to fix this. (You can try using setTimeout on the doh.run command, but it might be the case that the DOH robot clicks that div before parsing any doh commands.)
Another thing you might be able to do is add a sort of "wait" command to Selenium, or whatever shell command you are using to fire up the system.