appium / java-client

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

is getPerformanceData() working? #1450

Open game8149 opened 3 years ago

game8149 commented 3 years ago

Description

Hi, actually i can´t find getPerformanceData method from driver. I'm triying all classes and interfaces to instantiate and get that method, there isn't.

Did you remove that method?

GetPerformanceData

Environment

Code To Reproduce Issue [ Good To Have ]

My Pom.xml:

` <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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>com.realplazatestandroid</groupId>
<artifactId>realplazatestandroid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
    <dependency>
        <groupId>com.github.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>f726f3b</version> 
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>

</dependencies>

<!-- Added for AppCenter/Test runs -->
<repositories>
    <repository>
        <id>jcenter</id>
        <url>https://jcenter.bintray.com/</url>
    </repository> 
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository> 
</repositories>
<profiles>
    <profile>
        <id>repl</id>
        <dependencies>
            <dependency>
                <groupId>com.javarepl</groupId>
                <artifactId>javarepl</artifactId>
                <version>428</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <configuration>
                        <executable>java</executable>
                        <classpathScope>test</classpathScope>
                        <arguments>
                            <argument>-Djansi.passthrough=true</argument>
                            <argument>-classpath</argument>
                            <classpath />
                            <argument>javarepl.Main</argument>
                        </arguments>
                    </configuration>
                    <executions>
                        <execution>
                            <id>runRepl</id>
                            <phase>process-test-classes</phase>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile> 
</profiles>

`

My Java test class:

` package realplazatestandroid;

import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait;

import io.appium.java_client.MobileElement; import io.appium.java_client.android.AndroidDriver; import io.appium.java_client.android.AndroidTouchAction; import io.appium.java_client.remote.MobileCapabilityType;

import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.concurrent.TimeUnit;

import org.junit.rules.TestWatcher; import org.junit.runners.MethodSorters; import org.junit.Rule;

@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class androidTest {

private static  AndroidDriver<MobileElement> driver = null;
private static MobileElement CalculatorResult = null;

@BeforeClass
public static void startApp() throws MalformedURLException {
    DesiredCapabilities capabilities = new DesiredCapabilities(); 
    capabilities.setCapability("appPackage", "com.realplazago.app");
    capabilities.setCapability("appActivity", ".MainActivity");
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "android");
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.0");
    capabilities.setCapability("autoGrantPermissions", true);
    capabilities.setCapability(MobileCapabilityType.UDID, "MWS0216C02001198");
    capabilities.setCapability("browserstack.networkLogs", "true");
    capabilities.setCapability(MobileCapabilityType.APP,
            "D:\\app-release.apk");
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 7913);
    capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Appium");

    URL url = new URL("http://localhost:4723/wd/hub"); 
    driver = new  AndroidDriver<MobileElement>(url, capabilities);   
    driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); 
}

@Test
public void stage1_canStartAppInTest() throws MalformedURLException, InterruptedException {
    CaptureScreenshot("Launch");
    driver.launchApp(); 
    CaptureScreenshot("Starting");
}

@Test
public void stage2_canGestureAppInTest() throws Exception, InterruptedException { 
    driver.launchApp();
    if (driver != null) {
        AndroidTouchAction action = null;

        CaptureScreenshot("Starting"); 
        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.elementToBeClickable(By.xpath(
                "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.ImageView[1]")));
        MobileElement el1 = (MobileElement) driver.findElementByXPath(
                "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.ImageView[1]");
        el1.click(); 
    } else {
        throw new Exception("App launched dependency");
    }

}

private void CaptureScreenshot(String name) {
    File file = driver.getScreenshotAs(OutputType.FILE);
    try {
        FileUtils.copyFile(file, new File(name + ".png"));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
}

@After
public void after() throws Exception {
    if (driver != null) {
        driver.quit();
    }
}

} `

KazuCocoa commented 3 years ago

https://github.com/appium/java-client/search?q=getPerformanceData Seems there?

gaganchawla commented 3 years ago

I am facing the same issue, it says Cannot resolve getPerformanceData()

TSavin commented 2 years ago

Hello,

Same issue here. Can't resolve it either.