appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.22k stars 760 forks source link

The type AppiumDriver is not generic; it cannot be parameterized with arguments <MobileElement> #700

Closed vikramvi closed 7 years ago

vikramvi commented 7 years ago

Description

Environment

Details

Please provide more details, if necessary.

Code To Reproduce Issue [ Good To Have ]

Please remember that, with sample code; it's easier to reproduce bug and much faster to fix it. You can git clone https://github.com/appium/sample-code or https://github.com/appium/sample-code/tree/master/sample-code/apps and reproduce an issue using Java and sample apps. Also you can create a gist with pasted java code sample or put it here using markdown. About markdown please read Mastering markdown and Writing on GitHub

Ecxeption stacktraces

NA

Link to Appium logs

NA

TikhomirovSergey commented 7 years ago

@vikramvi Sorry for the late response.

I can't reproduce it. Could you try it with 5.0.2

This sample was compiled successfully

package com.saucelabs.appium;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;
import java.net.URL;

public class SomeSample {

    @Test
    public void tezt() throws Exception {
        File app  = new File("The absolute or relative path to an *.apk file");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
        capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
        AppiumDriver<MobileElement> driver = new AppiumDriver<>(
                new URL("http://target_ip:used_port/wd/hub"),
                capabilities);
    }
}
TikhomirovSergey commented 7 years ago

@vikramvi And something like that is compiled too

image

vikramvi commented 7 years ago

@TikhomirovSergey thanks for clarifying.

Annu1-cmd commented 3 years ago

Tried this still not working kindly help

valfirst commented 3 years ago

@Annu1-cmd could you please provide details?

Annu1-cmd commented 3 years ago

@valfirst I am using eclipse ide for java developers 4.6.0 Appium server version 1.13 Java version 1.8.0_271 TestNg 6.10 Node js v12.18.3 OS of pc windows 10 Mobile platform android 10

valfirst commented 3 years ago

@Annu1-cmd sorry, that's not enough, could you please provide an SSCCE (Short, Self Contained, Correct (Compilable), Example) ?

Annu1-cmd commented 3 years ago

Should I share the code sample too?

valfirst commented 3 years ago

@Annu1-cmd the project, the steps to run, the error details and etc., in other words everything that could be helpful to reproduce the problem

Annu1-cmd commented 3 years ago

import java.net.URL; import java.util.concurrent.TimeUnit;

import io.appium.java_client.AppiumDriver; import io.appium.java_client.MobileElement; import io.appium.java_client.remote.MobileCapabilityType; import io.appium.java_client.remote.MobilePlatform; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities;

public class Grocery60 {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    try {
        openGrocery();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        System.out.println(e.getCause());
        System.out.println(e.getMessage());
        e.printStackTrace();
    }

}
    public static void openGrocery() throws Exception
    {

        DesiredCapabilities cap=new DesiredCapabilities();
        cap.setCapability("deviceName", "One Plus 7");
        cap.setCapability("udid","98cd1718");
        cap.setCapability("platformName", "ANDROID");   
        cap.setCapability("platformVersion", "10");
        cap.setCapability("automationName","UiAutomator2");
        cap.setCapability("appPackage", "com.grocery60.inc.grocery");
        cap.setCapability("appActivity", "com.grocery60.inc.grocery.ui.SplashActivity");
        URL url=new URL("http://127.0.0.1:4723/wd/hub");
         AppiumDriver<MobileElement> driver = new AppiumDriver<MobileElement>(
                    new URL("http://target_ip:used_port/wd/hub"),cap);

I ran this on eclipse and I got this error The type AppiumDriver is not generic; it cannot be parameterized with arguments

valfirst commented 3 years ago

@Annu1-cmd it's still not enough, please, follow guidelines carefully: SSCCE (Short, Self Contained, Correct (Compilable), Example)

Sfofandi commented 2 years ago

Hello, i'm facing the same issue in my MacPro system.

  1. I am using eclipse ide Version: 2021-12 (4.22.0)
  2. Appium server version 1.22.0
  3. java version "17.0.2" 2022-01-18 LTS
  4. OS of MacPro Chip1
  5. Mobile platform iOS 11 pro

` import java.net.MalformedURLException; import java.net.URL; import org.openqa.selenium.remote.DesiredCapabilities; import io.appium.java_client.ios.IOSDriver; import io.appium.java_client.remote.AutomationName; import io.appium.java_client.remote.MobileCapabilityType; import io.appium.java_client.ios.IOSMobileCommandHelper; import io.appium.java_client.AppiumDriver; //ERROR 1 import org.openqa.selenium.WebElement;

public class base {

public static void main(String[] args) throws MalformedURLException {
    // TODO Auto-generated method stub

DesiredCapabilities d = new DesiredCapabilities();
    d.setCapability(MobileCapabilityType.DEVICE_NAME, "iPHONE 11 pro");
    d.setCapability(MobileCapabilityType.PLATFORM_NAME, "IOS");

    d.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);
d.setCapability(MobileCapabilityType.APP, "//users//desktop/UICatelog.app");

IOSDriver<IOSElement> driver = new IOSDriver<> (new URL("\"http://127.0.0.1:4723/wd/hub\""),d);

}

} Error message is here : Exception in thread "main" java.lang.Error: Unresolved compilation problems: The type IOSDriver is not generic; it cannot be parameterized with arguments IOSElement cannot be resolved to a type The type IOSDriver is not generic; it cannot be parameterized with arguments <>

at base.main(base.java:35)`
Sfofandi commented 2 years ago

I got the issue it was due to Java Client Version, i was used java client lates version 8.0 beta once i have used 7.6, it is working .

io.appium
<artifactId>java-client</artifactId>
<version>7.6.0</version>

kenzym04 commented 2 years ago

Don't use the latest java_client, use java_client 7.6.0 and your problem will be gone

gargpriya01 commented 2 years ago

Don't use the latest java_client, use java_client 7.6.0 and your problem will be gone

What can be the resolution if we have to use latest version 8.1.1 only?

valfirst commented 2 years ago

Please, read "Migration Guide", there you'll be able to find the resolution to the error from https://github.com/appium/java-client/issues/700#issuecomment-1054218255

KVarshini19 commented 1 year ago

Please, read "Migration Guide", there you'll be able to find the resolution to the error from #700 (comment)

i have read the doc, but i couldn't understand most of it. can you suggest something(like an explanation form ur side)

trachita commented 3 months ago

same issue in C# any help please ?