Hi,
Following this thread : Unknown command : touch/perform, the new version of Appium and the new version of the Java client, I was wondering if WebView support TouchApi ?
I update my project, run the code and get :
[…]
recordAgent() :: get boutton
recordAgent() :: click (just for test)
recordAgent() :: Create TA
recordAgent() :: Before Tap
tearDown() :: driver.quit() executed
FAILED: connect
org.openqa.selenium.WebDriverException: Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 39 milliseconds
Build info: version: ‘unknown’, revision: ‘2aa21c1’, time: ‘2016-08-02 14:59:43 -0700’
System info: host: ‘appiumlinux’, ip: ‘127.0.1.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘3.2.0-4-amd64’, java.version: ‘1.8.0_51’
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{app=/opt/workspace/thierry/SmartLYJavaTest/apk/smartly.apk, appPackage=eilyps.proto.socle, networkConnectionEnabled=true, warnings={}, appWaitPackage=eilyps.proto.socle, appWaitActivity=eilyps.proto.socle.Socle, databaseEnabled=false, deviceName=BH918NM50D, platform=LINUX, deviceUDID=BH918NM50D, appActivity=eilyps.proto.socle.Socle, desired={app=/opt/workspace/thierry/SmartLYJavaTest/apk/smartly.apk, platformVersion=5.1.1, platformName=Android, deviceName=android5.1}, platformVersion=5.1.1, webStorageEnabled=false, locationContextEnabled=false, takesScreenshot=true, javascriptEnabled=true, platformName=Android}]
Session ID: 2fa36d21-4670-4cdb-83e6-0a74c71dc16e
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:683)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:40)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at io.appium.java_client.AppiumDriver.performTouchAction(AppiumDriver.java:336)
at io.appium.java_client.TouchAction.perform(TouchAction.java:323)
at smartly.StartApplication.recordAgent(StartApplication.java:116)
at smartly.StartApplication.connect(StartApplication.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:822)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1130)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)
Still not supported or am I doing something wrong ?
My code :
public class StartApplication {
public static AndroidDriver<WebElement> driver;
public static AppiumDriver<WebElement> _driver;
public static DesiredCapabilities cap = new DesiredCapabilities();
@BeforeTest
public void startAppium() throws MalformedURLException, InterruptedException{
System.out.println("setUP() :: driver.AndroidDriver() executed");
cap.setCapability("platformVersion","5.1.1");
cap.setCapability("platformName","Android");
cap.setCapability("deviceName","android5.1");
cap.setCapability("app","/opt/workspace/home/project/apk/my.apk");
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"),cap);
System.out.println("AppLogin() :: driver.start() executed");
By webView = By.className("android.webkit.WebView");
WebDriverWait wait = new WebDriverWait(driver,300);
Set<String> availableContexts1 = driver.getContextHandles();
System.out.println("Total No of Context Found Before reaching WebView = "+ availableContexts1.size());
System.out.println("Context Name is "+ availableContexts1);
Thread.sleep(10000);
//4.1 Navigate to a portion of your app where a web view is active
wait.until(ExpectedConditions.visibilityOfElementLocated(webView));
// 4.2 Call getContext() method which will returns a list of contexts we can access, like 'NATIVE_APP' or 'WEBVIEW_1'
Set<String> availableContexts = driver.getContextHandles();
System.out.println("Total No of Context Found After we reach to WebView = "+ availableContexts.size());
for(String context : availableContexts) {
if(context.contains("WEBVIEW")){
System.out.println("Context Name is " + context);
// 4.3 Call context() method with the id of the context you want to access and change it to WEBVIEW_1
//(This puts Appium session into a mode where all commands are interpreted as being intended for automating the web view)
driver.context(context);
break;
}
}
Thread.sleep(10000);
}
@AfterTest(alwaysRun= true)
public void tearDown(){
driver.quit();
System.out.println("tearDown() :: driver.quit() executed");
}
@Test
public void connect() throws InterruptedException{
Thread.sleep(30000);
// Enregistrement de l'agent
this.recordAgent("AA","AAAAAAAAA");
}
private void recordAgent(String pstrOrga, String pstrAgent) throws InterruptedException {
// Recherche de l'élément orga
driver.findElement(By.id("ext-element-46")).clear();
driver.findElement(By.id("ext-element-46")).sendKeys(pstrOrga);
Thread.sleep(10000);
// Recherche de l'élément Agent
driver.findElement(By.id("ext-element-52")).clear();
driver.findElement(By.id("ext-element-52")).sendKeys(pstrAgent);
driver.findElement(By.id("ext-element-52")).submit();
Thread.sleep(10000);
System.out.println("recordAgent() :: get boutton");
WebElement btn = driver.findElementById("ext-button-98"); //(By.className("connectionBtn"));
System.out.println("recordAgent() :: click (just for test)");
btn.click();
System.out.println("recordAgent() :: Create TA");
TouchAction ta = new TouchAction(driver);
System.out.println("recordAgent() :: Before Tap");
ta.tap(btn);
ta.perform();
System.out.println("recordAgent() :: After Tap");
}
}