Reputation: 428
Getting Exception java.lang.NoClassDefFoundError: org/openqa/selenium/HasTouchScreen in Appium while clicking on an Element. I have used three locators(text,id,partialLinkText) in my code same Task but still getting the Same Exception Every time. PFB the App DOM Screenshot, code,Exception,jarfile version
I am trying to click on Text "Sign in Or" so i can automate the signin Module. But I got stuck in First Step only :(
Code
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.android.AndroidDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class searsLogin {
AndroidDriver driver;
@BeforeTest
public void setup() throws MalformedURLException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "ccdcb242");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "ANDROID");
capabilities.setCapability(CapabilityType.VERSION, "5.1.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.sears.android");
capabilities.setCapability("appActivity", "com.android.sears.activity.MenuDrawerActivity");
driver = (AndroidDriver) new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
}
@Test
void execution()
{
// driver.findElementByName("Sign in or").click();/// contains method
// boolean res = driver.findElement(By.name("Sign in or")).isDisplayed();
//boolean res = driver.findElement(By.xpath("//*[contains(text(),'Sign in or')]")).isDisplayed();
driver.findElement(By.partialLinkText("Sign in or")).click();
}
@AfterTest
public void end()
{
driver.quit();
} }
Exception Message
java.lang.NoClassDefFoundError: org/openqa/selenium/HasTouchScreen
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
Upvotes: 0
Views: 1397
Reputation: 21
In Appium v1.5.3 - Android,For Clicking on Locator "Name" try with :
driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Locator name\")").click();
For mentioned screenshot : driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Sign in or\")").click();
Upvotes: -1
Reputation: 595
You are using WEB locator for mobile. The correct XPath for this action would be following:
By.xpath("//*[@text='Sign in or']")
Upvotes: 0