How to close dialog by Selenium? - java

I want close browser file window pop-up (when I upload picture to Wordpress).
I tried
driver.close();
driver.findElement(By.id("set-post-thumbnail")).sendKeys(Keys.ESCAPE);
driver.switchTo().alert().dismiss();
but it doesn't work. How to close dialog by Selenium?

OS Specific dialogs like File Browser can not be controlled by Selenium.
It can handle only WebElements or JavaScript/Browser Alerts.
In this specific case, I think it is upload file browser.
Workaround may be to pass the absolute path if some text input field is provided along with "Browse" button.

Related

How can I get the network-"Status" of an webelement?

i am using Selenium Webdriver on Java and I am trying to get the network status of every element with a network status like you can see in the image below.
Is there any way to get the status?
Edit:
I guess I cannot upload images. If you press F12 to open the dev-tools there is a network menu. If you click on it, the status of every webelement will show up there.
AFAIK DevTools and Networking tab controls are not natively supported by Selenium.

LeanFT open browser window and navigate

I recorded a test case with Test Recorder tool in LeanFT with Chrome. When I execute it, it opens a new tab in Chrome, instead of starting a new instance of application. I tried to execute it in Firefox, but in this case it just opens browser window, doesn't navigate to given url.
Browser browser = BrowserFactory.launch(BrowserType.FIREFOX);
browser.navigate(env.LOGIN);
Error message:
com.hp.lft.sdk.GeneralLeanFtException: launch browser timeout occurred
When you execute a test, it's a new session.
This means that it's your responsibility to make sure that the environment in which your code is running is appropriate.
If you use .launch
while you have Chrome opened, it'll open a new tab
while you have Chrome closed, it'll open chrome (new window)
no matter if you have firefox opened or closed, it'll open a new firefox window
As you can see, the same method causes different behavior, depending on the browser and the state of the environment during the execution.
You need to adapt depending on your needs, and decide whether you want to .launch a browser or .attach to one.
.navigate should contain the URL such as browser.navigate(“www.google.com”) unless you have env.LOGIN set as a string of the url?

Taking control over window pop up to save a .zip file

How to take the control on window popup for saving a .zip file in window machine for firefox in java with selenium web-driver.
We use a Robot class for this purpose (java.awt.Robot).
http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

How to Handle Browser Popup (During the Download) using Java

currently we scrap the data from Websites using Web driver (Selenium)with Java, during that Scrapping we need to do some download process (i.e XML file Download), let me know how will handle the Browser Popup (save As Dialog) using Java
<a href="javascript:downloadXML()">
<img width="40" height="20" border="0" name="imag34" alt="Download" src="/pair/img/tabs/downloadxml.gif">
</a>
We are using the following code to click the above image
driver.findElement(By.xpath("(//img[#alt='Download'])[3]")).click();
After clicking that image, it will open a "Save as.." popup. How do we go to that popup and do testing on that?
This download popup is basically a window.open Javascript call with the URL of the XML file.
So this seems to be the relevant link :
How to switch to the new browser window, which opens after click on the button?
I've just solved this problem using the Robot class from Java. The Robot class allow you to simulate keybord press, in so doing you can work with TABs and Enters in order to execute the download.
This is actually a windows pop up and firebug will not able to detect this.If you are using windows OS then you can use AutoIT tool this will solve your problem.

None of the buttons(Save, Open, Cancel) attributes in IE developer tool not show up

Requirement is to download the Excel file from IE9 browser. I could able to click the Download button using Web driver in Java by which new window is displayed as shown below:
When I am trying to view the attributes of save button in IE developer tool, tool could not recognize them. Please help where is the problem with this window or how to resolve this issue.

Categories

Resources