我编写了一个简单的脚本,使用sikuli单击按钮。浏览器将打开并导航到提供的站点。但是,未按代码单击提供的图像。因此测试失败。
import org.testng.annotations.Test;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ISelect;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
public class NewTest {
@Test
public void demoMethod() throws FindFailed, InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\Kasturi\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.lk/");
String filepath = "C:\\Users\\Kasturi\\Desktop\\Kasturi\\Sikuli\\demoImgs\\";
String inputFilePath = "C:\\Users\\Kasturi\\Desktop\\Kasturi\\Sikuli\\demoImgs\\";
Screen screen = new Screen();
Pattern actionBtn1 = new Pattern(filepath + "Gmail.png");
screen.find(actionBtn1);
screen.click(actionBtn1);
Thread.sleep(3000);
driver.close();
}
}