Web UI automation in browsers (Chrome or Firefox) using Appium on real device

753 views
Skip to first unread message

Kirill Zhukov

unread,
Jul 29, 2014, 5:53:43 PM7/29/14
to appium-...@googlegroups.com
Hello everyone,
I am trying to run simple test on real device. Just go to the link google.com in Chrome.
First, I run server with command:
appium -U device_uuid --app-pkg com.android.chrome



It returns next:

info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
info
: Appium REST http interface listener started on 0.0.0.0:4723
debug
: Non-default server args: {"udid":"device_uuid","androidPackage":"com.and
roid.chrome"
}
info
: LogLevel: debug


{"status":0,"value":{"build":{"version":"1.2.0","revision":"e53f49c706a25242e66d36685c268b599cc18da5"}}}



After I am running this test:

package test;


import java.net.MalformedURLException;
import java.net.URL;


import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;


public class Test {
   
public static void main(String[] args) throws MalformedURLException {
     
WebDriver driver;
     
DesiredCapabilities cap = new DesiredCapabilities();
     driver
= new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), cap);
     driver
.get("http://www.google.com");
 
}
}


But I am getting this error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
 at test
.Test.main(Test.java:14)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
 at java
.net.URLClassLoader$1.run(Unknown Source)
 at java
.net.URLClassLoader$1.run(Unknown Source)
 at java
.security.AccessController.doPrivileged(Native Method)
 at java
.net.URLClassLoader.findClass(Unknown Source)
 at java
.lang.ClassLoader.loadClass(Unknown Source)
 at sun
.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java
.lang.ClassLoader.loadClass(Unknown Source)
 
... 1 more


Isaac Murchie

unread,
Jul 29, 2014, 6:08:18 PM7/29/14
to Kirill Zhukov, appium-...@googlegroups.com
Sounds like a class path issue. Do you have the Selenium jars available?



--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/d/optout.

Kirill Zhukov

unread,
Jul 29, 2014, 6:19:46 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
Hello, Isaac. Thank you for response.
I am pretty sure that I have right classpath and all needed jars. I was checking it whole yesterday :)

Kirill.

Isaac Murchie

unread,
Jul 29, 2014, 6:24:09 PM7/29/14
to Kirill Zhukov, appium-...@googlegroups.com
Ok. But com.google.common.base.Function is from Google Guava/Collections. It's included in the Selenium standalone jar. Otherwise you need to add it yourself (along with other stuff, possibly).

Kirill Zhukov

unread,
Jul 29, 2014, 6:27:46 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
In my classpath I have selenium-java-2.42.2.jar, selenium-java-2.42.2-srcs.jar, junit-4.11.jar, java-client-1.5.0.jar, java-client-1.5.0-javadoc.jar, and java-client-1.5.0-sources.jar. Did I miss something?
Thank you, Isaac.

Kirill Zhukov

unread,
Jul 29, 2014, 6:31:21 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
So, I added selenium-server-standalone-2.42.2 to the classpath and now I am getting next error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
 at org
.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:99)
 at org
.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:82)
 at org
.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
 at test
.Test.main(Test.java:14)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.SchemePortResolver

 at java
.net.URLClassLoader$1.run(Unknown Source)
 at java
.net.URLClassLoader$1.run(Unknown Source)
 at java
.security.AccessController.doPrivileged(Native Method)
 at java
.net.URLClassLoader.findClass(Unknown Source)
 at java
.lang.ClassLoader.loadClass(Unknown Source)
 at sun
.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java
.lang.ClassLoader.loadClass(Unknown Source)

 
... 4 more

Seems like I didn't import something...

Isaac Murchie

unread,
Jul 29, 2014, 6:33:02 PM7/29/14
to Kirill Zhukov, appium-...@googlegroups.com
I think Google can help you more than I can.

Kirill Zhukov

unread,
Jul 29, 2014, 6:33:38 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
Alright, then. Thanks :D

Kirill Zhukov

unread,
Jul 29, 2014, 8:02:38 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
Ok, so I missed jars from selenium's libs folder. Now I am getting next error:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity) (WARNING: The server did not provide any stacktrace information)



Here is my code:
package test;

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Test {
    public static void main(String[] args) throws MalformedURLException {
     WebDriver driver;
     DesiredCapabilities cap = new DesiredCapabilities();
     cap.setCapability(CapabilityType.BROWSER_NAME, "");
     cap.setCapability("platformName", "Android");
     cap.setCapability("deviceName", "HTC One_M8");
     cap.setCapability("appPackage", "com.android.chrome");
     cap.setCapability("appActivity", "com.android.chrome");

     driver = new RemoteWebDriver(new URL("http://localhost:4723/wd/hub"), cap);
     driver.get("http://www.google.com");
 }
}


What activity should I use then?

Isaac Murchie

unread,
Jul 29, 2014, 8:09:20 PM7/29/14
to Kirill Zhukov, appium-...@googlegroups.com

Kirill Zhukov

unread,
Jul 29, 2014, 8:12:33 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
Amazing! That works! Thank you, Isaac a lot!!!
One more question if you don't mind :)
There is any webview inspector for browsers except which is included in appium.exe?

Thanks!

Kirill Zhukov

unread,
Jul 29, 2014, 8:16:44 PM7/29/14
to appium-...@googlegroups.com, zhukov.k...@gmail.com
Actually I found this extension:
So I can switch between different devices and browsers and still to use developer tools. Awesome!

nitin gupta

unread,
Jul 30, 2014, 12:42:23 AM7/30/14
to appium-...@googlegroups.com
Hi kirill
 
Could you please provide me the code to automate chrome using appium...because i am getting session could not be created ,chromedriver unable to redirect to url error constantly,
Chrome always gets started but it does not redirect to any URL .only data is written in the URL bar.

Any help is appreciated
 

karthik holla

unread,
Jul 30, 2014, 10:19:17 PM7/30/14
to appium-...@googlegroups.com
Hi,

I am also currently facing the same issue where in I am able to launch chrome successfully but unable to pass the url. 'data;' would be written in the address bar and test fail. Currently I am using emulator with 4.3 version of android. Please provide some advice so as to overcome this issue. Many thanks in advance.

Thanks and regards,
Karthik

Reply all
Reply to author
Forward
0 new messages