-2

I am trying to write code in Selenium Webdrvier 3.0 + Java 1.8 + Chrome 53 for an application which needs to download and execute a .jnlp file after invoking a get(url). I am not sure whether this could be handled in Selenium webdriver or not? As I am new to selenium any help or guidance for handling these Windows Pop will be really helpful for me. Below is the piece of code :

if(browser.contains("CHROME") || browser.equalsIgnoreCase("chrome"))
{

    ChromeOptions options = new ChromeOptions();
    options.addArguments("--test-type");
    options.addArguments("--disable-extensions");                       
    capability = DesiredCapabilities.chrome();
    capability.setBrowserName("chrome");
    capability.setCapability(ChromeOptions.CAPABILITY, options);
}
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

browserDriver = new RemoteWebDriver(new URL(nodeAddress), capability);
browserDriver.manage().timeouts().pageLoadTimeout(1000, TimeUnit.SECONDS);          
browserDriver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
browserDriver.manage().window().maximize();
browserDriver.get(applicationUrl);
logger.info("WebDriver successfully defined with Session ID:" +  browserDriver.getSessionId() + ", Page Title:" + browserDriver.getTitle() + " and URL: " + browserDriver.getCurrentUrl());

Image attached : https://i.stack.imgur.com/esfpk.jpg

  • Please provide the code you have tried and the execution result including any error messages, etc. Also provide a link to the page and/or the relevant HTML. – JeffC Oct 10 '16 at 13:26
  • Hi @JeffC, I have added the piece of code which invokes a get(URL) of application, then it opens the attached Image Popup in Chrome which I am not sure hoe to handle from Selenium – Anshuman Singh Oct 10 '16 at 14:08

2 Answers2

0

The button you are trying to click is part of Chrome's UI and not part of the webpage so Selenium cannot interact with it. From the googling I've done, this is apparently an issue that people have reported as a bug and there is no consistent workaround.

JeffC
  • 22,180
  • 5
  • 32
  • 55
  • Hi Jeff, Thanks for replying. As I understand from your reply that this can not be handled as part of Selenium but is there any other tool or WA possible for handling these buttons? – Anshuman Singh Oct 10 '16 at 15:42
  • You might try a shortcut key for Keep... maybe ALT+K. If that doesn't work you could try TAB, etc. then ENTER to accept. Other than that, I don't know. You might be able to use some library and click on the button but I think there are inherent issues with those approaches with positioning the click correctly, etc. – JeffC Oct 10 '16 at 17:42
0

I've found a workaround via Selenium + Python (but similar thing should be feasible in Java too). In Python I just click programmatically on the notification in Chrome UI to allow downloading and installation of the jnlp file (with help of win32api and win32con - I needed it for Win only). See details here Webscraping is now much easier for me :)

Lukas
  • 2,034
  • 19
  • 27