serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
724 stars 518 forks source link

Serenity with Appium Could not instantiate class io.appium.java_client.AppiumDriver #235

Closed RJ05 closed 8 years ago

RJ05 commented 8 years ago

ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class io.appium.java_client.AppiumDriver: Could not instantiate class io.appium.java_client.AppiumDriver net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class io.appium.java_client.AppiumDriver

Serenity Property file:- webdriver.wait.for.timeout = 1000

webdriver.driver= appium

webdriver.base.url = http://www.google.com/

appium.hub = http://127.0.0.1:4723/wd/hub

appium.platformName = Android

appium.platformVersion = 5.1.1

appium.deviceName = e2f5c460

appium.browserName = Chrome

RJ05 commented 8 years ago

POM:-

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>AppiumSerenity</groupId>
<artifactId>framework</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <serenity.version>1.1.22-rc.11</serenity.version>
    <serenity.maven.version>1.1.22-rc.11</serenity.maven.version>
    <webdriver.driver>appium</webdriver.driver>
</properties>

<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>1.1.22-rc.11</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>1.7.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>2.42.2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>2.44.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ws.commons.util</groupId>
        <artifactId>ws-commons-util</artifactId>
        <version>1.0.2</version>
    </dependency>

    <dependency>
        <groupId>org.apache.xmlrpc</groupId>
        <artifactId>xmlrpc-client</artifactId>
        <version>3.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.xmlrpc</groupId>
        <artifactId>xmlrpc-common</artifactId>
        <version>3.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>2.4.3</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.lambdaj</groupId>
        <artifactId>lambdaj</artifactId>
        <version>2.3.3</version>
    </dependency>
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>3.3.0</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18</version>
            <configuration>
                <includes>
                    <include>**/features/**/When*.java</include>
                </includes>
                <systemProperties>
                    <webdriver.driver>${webdriver.driver}</webdriver.driver>
                </systemProperties>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.maven.version}</version>
            <dependencies>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-core</artifactId>
                    <version>${serenity.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

hazmeister commented 8 years ago

I've put together a pull request which might help. https://github.com/serenity-bdd/serenity-core/pull/331

YamStranger commented 8 years ago

Hello @hazmeister

Thanks for your contribution!!!

Your pull request merged and will be included in next release )

YamStranger commented 8 years ago

closed by mistake

wakaleo commented 8 years ago

@RJ05, @hazmeister: is this issue still present in 1.1.31?

hazmeister commented 8 years ago

Thanks @wakaleo , ran a test this morning with Serenity 1.131 and Appium 1.5.1 and had no problems.

hypery2k commented 8 years ago

I'm getting the same error. Trying a sample project to run with appium

# start appium
appium &
mvn verify -Dappium.hub=http://127.0.0.1:4723/wd/hub -Dwebdriver.driver=appium -Dappium.platformName=iOS -Dappium.browserName=Safari -Dappium.deviceName="iPhone 5"

But getting the following error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 52.481 sec <<< FAILURE! - in demo.tests.GoogleSearchFailTest
googleSearchFailTest(demo.tests.GoogleSearchFailTest)  Time elapsed: 52.481 sec  <<< ERROR!
net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate class io.appium.java_client.AppiumDriver
    at demo.steps.GoogleSteps.googleSearchPage(GoogleSteps.java:22)
    at demo.steps.GoogleSteps.inputSearchTerm(GoogleSteps.java:57)
    at demo.steps.GoogleSteps.performSearch(GoogleSteps.java:73)
    at demo.tests.GoogleSearchFailTest.googleSearchFailTest(GoogleSearchFailTest.java:30)
hypery2k commented 8 years ago

I've found the error. Please reopen this issue. The error is related the browser redimension-Method. If setting browser dimensions it's not working:

Method is not implemented (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 7 milliseconds

The method supportsScreenResizing should return false for appium. I'll create a PR and a test for it.

wakaleo commented 8 years ago

Thanks for your help!

wakaleo commented 8 years ago

Released in 1.1.34

hypery2k commented 8 years ago

thanks. Will test later ;)

hypery2k commented 8 years ago

the original error is gone. So this one can be closed.

szarlatan commented 8 years ago

Hi,

I know that the ticket is already closed, but it has all the history.

Using CucumberWithSerenity runner and serenity-core:1.1.36 I got exactly same error

[main] ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class io.appium.java_client.AppiumDriver: Could not instantiate class io.appium.java_client.AppiumDriver

The only difference from the sample project mentioned above is that I have a hybrid app under test. On the other hand it should not be a serious problem as it contains one huge webView, so basically all content of the app is web-based.

Hints?

BR, Kris

hazmeister commented 8 years ago

That error can happen for many reasons - it might be worth raising a new issue or asking over on the Google group. What options are you starting Appium with?

cliviu commented 8 years ago

hi @szarlatan , can you please post more from your error log ? As @hazmeister mentioned, it may also be a problem of the appium options that you are using for starting the test, for example, in serenity.properties:
appium.deviceName= e2f5c460 appium.browserName = Chrome

szarlatan commented 8 years ago

So, @hazmeister @cliviu

I run the tests with such appium section (this is the exact properties file as there is nothing more at the moment):

webdriver.driver = appium appium.platformName = Android appium.deviceName = Galaxy Tab 4 appium.platformVersion = 5.0.2 appium.app = /Users/krisu/git/serenitypoc/app.apk appium.autoWebview = true

Interesting part is that looking the Appium server logs I can see that capabilities are injected properly, more over a session is created with device and the application is being installed and launched. After that, when the code execution gets to the elements interaction logic, it fails immediately.

What else I've found that might be quite a root cause of my problem is following

Caused by: org.openqa.selenium.SessionNotCreatedException: A new session could not be created. Details: Problem getting session data for driver type AndroidDriver; does it implement 'get driverData'?

BTW, would dev group be better to seek for assistance with such problems? Or users will do as well?

Kris.

cliviu commented 8 years ago

Somehow, the AndroidDriver is created twice from your code (the second time it fails ), is it possible to post more possible problem cause from logs ? Have you also check the appium server logs ?

szarlatan commented 8 years ago

That is quite probable, yesterday going through the appium log I saw that second session has been created and the problem (for me) started with proxying one to another.

Just not to flood the message, I attach two files with entire stacktrace and appium server log.

stacktrace.txt appium-server.txt

[EDIT] I can even share the project code as it is a simple POC.

Kris.

hazmeister commented 8 years ago

@szarlatan get your deviceid from adb devices (run via the command line) and use that as the device name.

szarlatan commented 8 years ago

@hazmeister that gave me no changes.

cliviu commented 8 years ago

Hey Kris, please try the following library combination. First of all please run appium server 1.5.3 As mvn dependencies : serenity-core1.1.37-rc.9, io.appium.java-client 4.1.2. Let me know how it goes :-)

szarlatan commented 8 years ago

Hey @cliviu.

I ran it the configuration you've described, but no changes either.

The only change that I found is the DARKROOM COUNT: 1 presented right below the stacktrace I sent yesterday.

I will report this on google group in a minute too. Which do you think will be better, dev or users?

Kris.

cliviu commented 8 years ago

Hey Kris, Can you please type "mvn dependency:tree" in your project directory and post the output here in a file ? I was able to reproduce your issue yesterday using an older serenity-core version. Maybe there is some dependency problem somehow.
Thanks!

szarlatan commented 8 years ago

Hey @cliviu,

you will find it in a file attached. And it seems that there is a hope ;-) mvn-dependency-tree.txt

Regards, Kris.

cliviu commented 8 years ago

Hey Kris, I tried with your libraries combination, I cannot reproduce the problem with my test code. Please share your project code, as you said is a POC and it can be shared. Thanks, Liviu

szarlatan commented 8 years ago

Here it is. The only thing I cannot share with you is the app under test itself, as it is a regular project for us ;-) Another thing I found as potential root cause of the problem - I set the appium driver capability autoWebview = true to automatically switch to webview on start (as our app is just a huge webview). If I comment this out the test will break of course, but with a different root cause and obviously stacktrace.

serenity-poc.zip

cliviu commented 8 years ago

Hi Kris, thanks for your upload. regarding the webview , I have found the following appium issue : https://github.com/appium/appium/issues/5089. which may explain why appium.autoWebview = true fails. Tell me a bit about the architecture of your application ... I think you should use @AndroidFindBy annotations in your PageObjects ...

szarlatan commented 8 years ago

I went through the appium issue and what I found is that relates strongly to Selenoid not Appium engine. Moreover, I use this autoWebview = true capability in previous, appium-only, approach to our hybrid app automation and it is working just fine. I thought that moving over to Serenity will give us much more value with great reporting and possibility to add cucumber easily.

Our app is simply a fullscreen webview wrapped by native Android apk package. So the content of the app is a web page. I tried to get driver's contexts but fail, as my driver seems to be null, even if wrapped with @Managed annotation. So maybe I doing something terribly wrong? @cliviu, have you found my code senseless in any way?

pisarenco92 commented 8 years ago

@szarlatan your tests failed in webview?

szarlatan commented 8 years ago

@pisarenco92 basically, yes.

As I mentioned our application is simply a fullscreen webview wrapped with native Android apk archive.

When I am using appium automation engine, with driver capability autoWebview set to true, then the tests fail right away after launching the application (what is handled by Appium server), without clicking on even single item, and the driver session hangs. Failure reason is

[main] ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class io.appium.java_client.AppiumDriver: Could not instantiate class io.appium.java_client.AppiumDriver

and the stacktrace can be found in posts above.

When I run the previous project that base simply on Appium, without the Serenity, mentioned autoWebview flag was working properly without problems.

pisarenco92 commented 8 years ago

@szarlatan Try to add: appium.nativeWebScreenshot = true capability

szarlatan commented 8 years ago

@pisarenco92 Nope, that did not change a thing.

I started to wonder if Serenity can test the native/hybrid apps using AppiumDriver, so rather AndroidDriver or IOSDriver?

Thucidides core throws net.thucydides.core.webdriver.UnsupportedDriverException what brings to mind that appium driver might not be fully supported and it covers functionality like opening the Chrome browser on a device, than Chrome WebDriver is instantiated and proceeds with testing. Does it make sense?

cliviu commented 8 years ago

try to set appium.browserName=Chrome I will need a similar application with the one that you are testing. Just one html page packed in an apk.

cliviu commented 8 years ago

I think that the only finder annotations supported at the moment by serenity with the AppiumDriver are @FindBy(accessibilityId = ... ) @AndroidFindBy(id = "..") @iOSFindBy(id=...). I was not able to reproduce your exception using your pom.xml, maybe it has something to do with the application under test ...

vikramvi commented 7 years ago

@hypery2k @cliviu in case grid setup what value to pass for -Dappium.deviceName ?

I'm trying to run test cases in parallel for native app on multiple android emulators

Thanks in advance.

vikramvi commented 7 years ago

@hypery2k @cliviu I'm struck with this issue since last 2 weeks, your guidance in this will be of great help. Thanks in advance.

rahulkulkarniyahoo commented 7 years ago

Found similar issue: https://stackoverflow.com/questions/44785430/serenity-selenium-launching-simulator-on-macos-instead-of-physical-device The error is deceiving as I have set the following values in the serenity.properties file appium.deviceName=iPhone_Test1 appium.platform=Mac appium.app=/users/rahulk/documents/ipas/TabbedTest_Rahul.app appium.platformName=iOS appium.automationName=XCUITest appium.platformVersion=10.3.2 appium.uidid=904ac3b4c6xxxxxxxxxxxxx979 appium.hub=http://127.0.0.1:4723/wd/hub

When I change the values and provide iOSsimulator values, it works fine. Changing values to use Android Device works fine. Changing values to use Android Simulator works fine.

Also performed: xcrun instruments -s devices on my mac and i can see the my physical device listed.

Using CucumberWithSerenity.class as my runner. Any clues what is setup incorrectly?

kanojiyanviod commented 5 years ago

Hi, I am trying to connect test object instance of saucelab where i am connecting testObject with testobject key, using below serenity property file :

webdriver.driver= appium

appium.hub = http://localhost:4723/wd/hub

saucelabs.test.name=AppiumWordPressWithSauce saucelabs.target.platform=Windows saucelabs.testobjectApiKey=27E3B8CC6BDF4ABHH8ACA578124FCDA4C

appium.hub = http://127.0.0.1:4723/wd/hub

appium.platformName = Android appium.platformVersion = 5.1.1 appium.deviceName = Samsung_Galaxy_A5_2017_real

appium.browserName = Chrome

appium.app=sauce-storage:WordPress.zip

appium.appPackage=com.ombiel.campusm.unsw

Running From IDE

saucelabs.url=http://:@ondemand.saucelabs.com:80/wd/hub

saucelabs.user.id=

saucelabs.access.key=


getting error as

ERROR net.thucydides.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class io.appium.java_client.AppiumDriver: Could not instantiate new WebDriver instance of type class io.appium.java_client.AppiumDriver (The browser under test or path to the app needs to be provided in the appium.app or appium.browserName property. net.thucydides.core.webdriver.UnsupportedDriverException: Could not instantiate new WebDriver instance of type class io.appium.java_client.AppiumDriver (The browser under test or path to the app needs to be provided in the appium.app or appium.browserName property.

please help

kanojiyanviod commented 5 years ago

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>net.serenity-bdd.appium.integration</groupId>
<artifactId>serenity-appium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Serenity Appium Integration Test Cases</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <serenity.version>1.7.4</serenity.version>
    <serenity.cucumber.version>1.6.3</serenity.cucumber.version>
    <serenity.maven.version>1.7.4</serenity.maven.version>
</properties>

<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray</name>
        <url>http://jcenter.bintray.com</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray-plugins</name>
        <url>http://jcenter.bintray.com</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>

        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.7</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>1.7.0</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20.1</version>
            <configuration>
                <skip>false</skip>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.maven.version}</version>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

My POM

baligit commented 4 years ago

I have the issue : https://github.com/appium/java-client/issues/1343 Any idea ?

AlvaroDucuara13 commented 2 years ago

I have the following problem. somebody could help me?:

[Test worker] ERROR - Could not instantiate new WebDriver instance of type class io.appium.java_client.AppiumDriver (Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.Empresa.appcompania' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Cannot start the 'com.Empresa.appcompania' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Activity name '.MainActivity' used to start the app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity