Appuim - 长按并同时截屏

时间:2016-04-25 18:54:59

标签: java android selenium appium

是Appium能够长按并同时截屏吗?

 public void press(By by) throws IOException {
    WebElement el = driver.findElement(by);
    TouchAction action = new TouchAction(driver);
    action.longPress(el);}

之后我申请截屏

  public void screenshot(String filename) throws IOException {
    File srcFile=driver.getScreenshotAs(OutputType.FILE);
    File targetFile=new File("./Screenshots/Navigation/" + generateCurrentDate()+ "/"+ filename +".jpg");
    FileUtils.copyFile(srcFile,targetFile);}

但它会执行长按,之后会截屏。我需要同时长按和截图。

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:0)

这就是我解决的问题

<?php

// get users IP address
$ip = $_SERVER['REMOTE_ADDR'];

// find out if user has already been blocked
$getblockedq = 'SELECT ip FROM blocked_logins WHERE ip = :ip';
$getblocked = $muc->prepare($getblockedq);
$getblocked->execute(array(':ip' => $ip));
$total = $getblocked->fetchColumn();

if ($total > 0) {
    // user is blocked, do not proceed
}

// find number of failed logins within past 15 mins
$getfailedq = 'SELECT Count(*) AS failed FROM failed_logins WHERE ip = :ip AND attempted > Date_sub(Now(), INTERVAL 15 minute)';
$getfailed = $muc->prepare($getfailedq);
$getfailed->execute(array(':ip' => $ip));
$total = $getfailed->fetchColumn();

if ($total <= 2) {
    // looks good, attempt to login
} elseif ($total <= 10) {
    // you must wait x seconds...
} elseif ($total <= 1000) {
    // display captcha
} else {
    // block user
}

然后你可以拍一张照片。但只有当我想从hold中释放该元素时,它才会给我错误。现在我不介意释放它。现在很好