我正在尝试单击桌面应用程序中的按钮。当我使用TestNG应用程序成功运行时运行脚本,但随后焦点切换到监视器屏幕的右上角。应用程序最小化。以下是我的代码。使用以下代码,我无法将元素集中在 Surface Pro 中。在其他戴尔,联想触摸屏机器上运行良好
package clientAutomation;
import java.io.IOException;
import java.net.URL;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
public class NewTest {
@Test
public void test() throws IOException{
DesktopOptions options= new DesktopOptions();
options.setApplicationPath("application pat");
System.out.println("Application launched successfully");
try{
WiniumDriver driver=new WiniumDriver(new URL( "http ://localhost :9999"), options);
Thread.sleep(10000);
driver.findElement(By.name("Skip")).click();
Thread.sleep(3000);
driver.findElement(By.className("className")).sendKeys("Welcome2019!");
Thread.sleep(3000);
driver.findElement(By.name("Next>")).click();
Thread.sleep(3000);
driver.findElement(By.name("Skip")).click();
Thread.sleep(3000);
driver.findElement(By.name("Skip")).click();
Thread.sleep(3000);
driver.findElement(By.name("Skip")).click();
Thread.sleep(4000);
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
}
应该单击按钮。