In my Selenium project word document is being opened as a report.
How can I identify whether the document is opened or not using Selenium webdriver.
In short, unless the document opens utilizing the browser, then you can't with Selenium WebDriver. Selenium only has access to what the browser itself has access to. If the browser is handing this off to the OS or MS Office to handle the specifics then you lose access to it.
You could try to intercept the communication and determine when the code to call the word document to open is executed, but that would be custom code and depend on the application itself.
Personally I think the best way would be to instantiate an OpenQA.Selenium.Interactions.Actions class instance and then specify the specific keystrokes to capture the screen and save it. Then switch back to the browser window driver.switchto().window() and continue. Then you can verify manually that the screen capture has the word document in it after the test is completed.
Related
I am using webdriver.io framework. At my application, I have a button that opens a Windows Open prompt (Native), and there I need to choose a folder/file and click Open.
Then returning to my application and continue.
Is there a way to move focus on to this window and control it (Select a path and click Open)?
If not- Is there any other solution someone can offer?
The short answer is probably not, you can't control native dialogs from webdriver.
If it's a file input type for which you want to set a file, you might possibly use webdriver to evaluate a piece of javascript to set the HTMLInputElement.files value of the input element.
This works in modern browsers as mentioned in the mozilla docs
I am new to selenium automation testing, Is there a way to kill remotewebdriver session without closing the browser?
Also is it possible to wait for user intervention (say Click on certain element)
I googled my queries, but couldn't find any answer I was looking for.
EDIT 1:
I was doing a little POC on a customer relation service app, where csr will click a button and it will open an external application, and take him to a form, where some information will be populated automatically by selenium and some information will be populated by csr's manual input.
So far in the Project, I have a spring mvc 4 application. There is a REST controller. Upon posting a json to my controller, it call invokes a service method which opens selenium remote webdriver.
1.I want my browser to stay opened until user press submit button.
2.I want to take csr to the desired page and lose the control of selenium, afterwards csr will submit the page or close the browser depending on situation.
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.
In Selenium, When I try to open MS Word Document from Firefox browser, dialog box pop-ups which I am unable to identify through Selenium. Can any one please help me in identifying the dialog box (How to capture ID or window ID) through selenium?
You can use autoit.Just Download the autoit software from given link and install it.
AutoIt Site
Write a few lines script in autoit according to your need and call the compiled exe before the line which causes that window to appear.
The Autoit WIndow Info Tool will help you in identifying the ID and class for the desired controls.
I currently using Selenium Web driver.(2.24.1)- Programming Language--JAVA
I want to save a web Page in HTML only Format, so i am using Robot class to save webpage.
I am using this Save functionality in a loop (for n times).
This is working good for for few cases in the loop but randomly( may be 1st time or 3rd times...nth times) it fails with an error message "Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present (WARNING: The server did not provide any stacktrace information)"
Well it depends on what the Modal Dialog was, but there are three things I would check.
First Most likely you'll need to upgrade your Web Driver
I noticed you're using Webdriver 2.2.24, if you're also using FireFox as the browser you'll want to upgrade your WebDriver to 2.2.26 or higher. There was a change to "Prevent firefox from updating, checking and warning for extension and plugin updates" IF any of those things occur they also will raise a modal dialog.
Second It could be a dialog raised by the site you're testing
javascript alert() or a window.Prompt() are examples of modal dialogs the site be raising to do any number of things. You can use the WebDriver to interact with these dialogs.
Third If it's none of the above get a screen capture of the dialog
The dialog may not be something that you can access through the WebDriver API so you need to write code to get capture the entire screen (should be easy with some googling). Or you can record a video session when running the code.