1

I have recently written a Selenium program in Java that works perfectly with the FireFoxDriver(). My step 2 is to be able to run this program on my Android device with Selendroid. I went on their website here and have been able to download the jar and connect to their localhost with port:4444.
However, when I try their example, Eclipse doesn't recognize the SelendroidDriver() and suggests me to go back to WebDriver().
Here is their code:

SelendroidCapabilities capa = new SelendroidCapabilities("io.selendroid.testapp:0.10.0");

// My error appears when I create the new SelendroidDriver().
WebDriver driver = new SelendroidDriver(capa);
WebElement inputField = driver.findElement(By.id("my_text_field"));
Assert.assertEquals("true", inputField.getAttribute("enabled"));
inputField.sendKeys("Selendroid");
Assert.assertEquals("Selendroid", inputField.getText());
driver.quit();

I have also noticed that the SelendroidDriver class does not appear in my files although I downloaded the Selendroid jar file, version 0.10.0.

Chiquelo
  • 162
  • 2
  • 13
  • Did you add the .jar to the classpath in Eclipse, after downloading? – SiKing May 22 '14 at 19:49
  • I did exactly like they recommend in http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project – Chiquelo May 22 '14 at 19:55
  • In your Eclipse project, can you see the entry 'Referenced Libraries'? If you expand that, can you see your .jar in there? – SiKing May 22 '14 at 20:08
  • Yes, it's the weirdest thing. I see selendroid-standalone-0.10.0-with-dependencies.jar – Chiquelo May 22 '14 at 20:16
  • It should be good enough to have just selendroid-standalone-0.10.0.jar, but this should work too. What `import`s do you have at the top of your class? If you do not have enough, do Source > Organize Imports. – SiKing May 22 '14 at 22:25
  • Still not happening. I think I am on my own on this one... I ran the program and it printed: # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows – Chiquelo May 23 '14 at 13:44

3 Answers3

2

For those of you who are curious about how I fixed my problem, here is what I did: I went to this site to get the selendroid-client jar file corresponding to the standalone version I had. Downloading the standalone jar file was somehow not enough.

Chiquelo
  • 162
  • 2
  • 13
0

I was facing the same problem till I found the SelendroidDriver class here. Import this and change the package name according to your project.

SelendroidDriver.java has classes implementing interface methods, which in Java 1.6 can be annotated with @Override. However, in Java 1.5, @override could only be applied to methods overriding a superclass method.

Go to your project preferences and set the "Java compiler level" to 1.6 and also make sure you select JRE 1.6 to execute your program from Eclipse.

After adding this class, you would still see multiple dependency errors, but now in the SelendroidDriver.java file. You can import these classes now to counter these errors. Ensure that the package hierarchies are maintained correctly, in accordance with the GitHub directories and your working project.

After importing all these classes, the constant fields SWITCH_TO_CONTEXT, GET_CONTEXT_HANDLES and GET_CURRENT_CONTEXT_HANDLE were not being resolved. I used a poor workaround of changing them to some other available constant field for testing this sample.

  • I had tried that at first. However, I never reached the SWITCH_TO_CONTEXT part. I am curious, what do you mean by poor workaround? – Chiquelo May 23 '14 at 13:59
  • Are you suggesting to import the .java sources rather than the .jar file? If yes, this is most definitely wrong! – SiKing May 23 '14 at 14:26
  • @Chiquelo I'm tweaking the functionality of the `SelendroidDriver` class when I change the mentioned constant fields to something else. That's what I'm pointing to as a poor workaround. @SiKing I'm not very well-versed with Java. Started working on this project a week back. I guess the word import is wrong to use here. I meant using the mentioned .java files to rule out the dependencies. – purplegrunge May 24 '14 at 05:27
0

I struggled a lot with this error and finally came to know that the paths have been changed in the latest releases. Use these paths and it shall work:

import io.selendroid.common.SelendroidCapabilities;

import io.selendroid.client.SelendroidDriver;

Tested this for versions 0.15.0 & 0.17.0

Sugandha Jain
  • 333
  • 2
  • 6