Friday 8 May 2015

Selenium:Window based popups Handling using sikuli

package sikuli;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class SikuliSelenium {

    WebDriver driver;
     @Test
     public void testTestScenario1() throws Exception
     {
        // And now use this to visit Google

         driver.get("http://www.seleniumhq.org/");
         driver.findElement(By.xpath(".//*[@id='menu_download']/a")).click();
         Thread.sleep(4000);
         driver.findElement(By.xpath(".//*[@id='mainContent']/p[3]/a")).click();
       
         //Create and initialize an instance of Screen object  

         Screen screen = new Screen();

         //Add image path 

         Pattern image = new Pattern("C:\\Users\\IN00914\\Desktop\\Payslips\\save.png");

         //Wait 10ms for image

         screen.wait(image, 10);
         //Click on the image

         screen.click(image);

         Thread.sleep(8000);
           }
     @BeforeClass
        public void beforeClass() {

            System.setProperty("webdriver.firefox.bin",
                    "C:\\Users\\Ramesh\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
            driver = new FirefoxDriver();
            driver.manage().window().maximize();

        }

        @AfterClass
        public void afterClass() {
            driver.quit();
        }
}

No comments:

Post a Comment