线程" main"中的例外情况java.lang.NoSuchMethodError:org.openqa.selenium.WebDriverException.addInfo(Ljava / lang / String; Ljava / lang / String;)V

时间:2016-07-22 09:17:16

标签: android selenium webdriver appium

我必须选择公交车的各个座位,因为它是CANVAS元素。我需要使用touchaction来点击该元素的(x,y)坐标。

我得到了这个例外:线程中的异常" main"

  

java.lang.NoSuchMethodError:   org.openqa.selenium.WebDriverException.addInfo(Ljava /郎/字符串; Ljava /郎/字符串;)V

在这一行:

  

" action.tap(element,144,680).perform();"

为什么会发生这种错误?

代码部分:

import io.appium.java_client.MobileDriver;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.FindBy;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;
import android.graphics.Path;

public class Bus {

    public static String URL = "http://m.bus.in";
    public static WebDriver driver;
    public AndroidDriver androiddriver;
    static DesiredCapabilities DCapabilities = new DesiredCapabilities();
    static String imagepath = "C:\\Sikuli\\upper.png";
    public static void main(String[] args) throws MalformedURLException,
        InterruptedException, FindFailed {
            DCapabilities.setCapability("automationName", "appium");
            DCapabilities.setCapability("browserName", "Chrome");
            DCapabilities.setCapability("version", "4.2");
            DCapabilities.setCapability("deviceName", "Basrock");
            DCapabilities.setCapability("platformName", "Android");

            driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                DCapabilities);

            driver.get(URL);
            Thread.sleep(5000);

            System.out.println("Search clicked from nav bar..");

            Thread.sleep(1000);
            driver.findElement(By.id("srcCity")).click();
            driver.findElement(By.className("search-city")).clear();
            driver.findElement(By.className("search-city")).sendKeys(
                "Bangalore");
            Thread.sleep(1000);

            List < WebElement > allElements = driver.findElements(By.className(
                "sugg-list"));
            int listsize = allElements.size();
            for (int i = 0; i < listsize; i++) {
                String sValue = allElements.get(i).getText();
                System.out.println(sValue);
            }

            driver.findElement(By.xpath("//li[@value='122']")).click();
            System.out.println("Bangalore selected from the list");

            driver.findElement(By.id("destCity")).click();
            driver.findElement(By.className("search-city")).clear();
            driver.findElement(By.className("search-city")).sendKeys("Goa");
            Thread.sleep(1000);

            List < WebElement > allElements1 = driver.findElements(By.className(
                "sugg-list"));
            int listsize1 = allElements.size();
            for (int i = 0; i < listsize1; i++) {
                String sValue1 = allElements1.get(i).getText();
                System.out.println(sValue1);
            }

            driver.findElement(By.xpath("//li[@value='210']")).click();
            System.out.println("Goa selected from the list");

            driver.findElement(By.className("gtm-tomorrow")).click();
            System.out.println("Selected tomorrow..");

            driver.findElement(By.id("search_bus")).click();
            System.out.println("Buses searched..");

            Thread.sleep(1000);
            driver.findElement(By.xpath(
                "//*[@id='reactContentMount']/div/span[1]/div/ul/li[1]"
            )).click();
            System.out.println("Bus Selected..");

            Thread.sleep(3000);
            driver.findElement(By.id("bpSelect")).click();
            System.out.println("BoardingPoint clicked..");

            driver.findElement(By.xpath(
                "//*[@id='bpdp-holder']/div/div/div/div/div[1]/ul/li[1]"
            )).click();
            Thread.sleep(1000);
            driver.findElement(By.xpath(
                "//*[@id='bpdp-holder']/div/div/div/div/div[2]/ul/li[1]"
            )).click();
            System.out.println("Boarding and Droping point selected..");

            Thread.sleep(1000);

            WebElement element = driver.findElement(By.xpath(
                "//*[@id='reactContentMount']/div/div/div[4]/div/div/div/div/div/div[4]/canvas"
            ));
            TouchAction action = new TouchAction((MobileDriver) driver);

            System.out.println("performed 1");
            Thread.sleep(1000);

            action.tap(element, 144, 680).perform();
            System.out.println("performed 2");
        }

}


Exception in thread "main" java.lang.NoSuchMethodError: org.openqa.selenium.WebDriverException.addInfo(Ljava/lang/String;Ljava/lang/String;)V
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:609)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:180)
    at io.appium.java_client.AppiumDriver.performTouchAction(AppiumDriver.java:293)
    at io.appium.java_client.TouchAction.perform(TouchAction.java:301)
    at Redbus.main(Redbus.java:133)

0 个答案:

没有答案