0
votes

I'm installing Firefox extension using automation. I'm using below code. but I'm getting an error.

enter image description here

package com.toolbar.pages;

import java.io.Console;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.sikuli.script.FindFailed;
import org.sikuli.script.ImagePath;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

public class FFInstallationpage {

	@SuppressWarnings("deprecation")
	public static void main(String[] args) throws FindFailed, InterruptedException {
		
		WebDriver driver;
		
		DesiredCapabilities capabilities = new DesiredCapabilities();
		
		System.setProperty("webdriver.gecko.driver", "/Users/venkata.b/Downloads/geckodriver");
		
		driver =new FirefoxDriver(capabilities);
   
        driver.manage().window().maximize();
        
        driver.get("https://toolbar.rakuten.co.jp/ff/");
      
        driver.findElement(By.xpath("//img[contains(@src,'https://image.infoseek.rakuten.co.jp/content/toolbar/ff/top/main_btn.png')]")).click();
        
        Thread.sleep(5000);
   
        driver.findElement(By.xpath("//img[contains(@src,'https://image.infoseek.rakuten.co.jp/content/toolbar/install_btn.gif')]")).click();
    
   
       
        Alert alert = driver.switchTo().alert();
        
        driver.switchTo().alert();
        
        alert.accept();

Error

Exception in thread "main" org.openqa.selenium.NoAlertPresentException: No modal dialog is currently open Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:31.527Z' System info: host: 'RINMAC297', ip: 'fe80:0:0:0:c44:2da2:148c:dc85%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities {acceptInsecureCerts: false, browserName: firefox, browserVersion: 57.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:headless: false, moz:processID: 8761, moz:profile: /var/folders/b0/rz6ystbx6q7..., moz:webdriverClick: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, platformVersion: 16.7.0, rotatable: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}} Session ID: 3cb929c6-a392-b247-a6ec-72af24f1ab6f at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:657) at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.alert(RemoteWebDriver.java:986) at com.toolbar.pages.FFInstallationpage.main(FFInstallationpage.java:50)

1
The website is probably not using a typical alert. Try seeing if the "alert" is an element of the actual webpage.DCON
You have imported Sikuli. Didn't that solved the problem ?Manmohan_singh
@Manmohan_singh sikuli findfailed issueVenkat

1 Answers

0
votes

If you expect alert but sometime it may not open.You can handle it using try and catch

try {
Alert alert = driver.switchTo().alert(); 

        driver.switchTo().alert(); 

        alert.accept(); 
}

catch (org.openqa.selenium.NoAlertPresentException e){
 System.out.println("No alert present");      
}