gpt4 book ai didi

java - 能够安装亚马逊应用程序但无法打开它

转载 作者:太空宇宙 更新时间:2023-11-04 12:06:35 25 4
gpt4 key购买 nike

enter image description here在 apk 文件的帮助下,我可以安装 Android 应用程序,但它无法打开。请查看我的代码一次:

package Test1;

import io.appium.java_client.android.AndroidDriver;

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

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class Amazon_LogIn_Test {
private static AndroidDriver driver;

@BeforeMethod
@Test
public void setUp() throws Exception {

File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/Amazon/");
File app = new File(appDir, "com.amazon.mShop.android.shopping-5.2.3-502030- minAPI9.apk");

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("deviceName", "BECUPJTWGA7HAQQK");
capabilities.setCapability("platformVersion", "5");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.amazon.mShop.android.shopping");
capabilities.setCapability("appActivity", "com.amazon.mShop.splashscreen.StartupActivity");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(10000);

// Click on Shop by Deparment link
driver.findElement(By.id("com.amazon.mShop.android.shopping:id/search_edit_text")).click();
// Click on Main menu
driver.findElementByClassName("android.widget.ImageView").click();
// Click on Home link under Main menu
driver.findElement(By.name("Home")).click();
// Click on Sign In link on the Home Screen
driver.findElementByName("Sign inHello. Link").click();

Thread.sleep(10000);
driver.findElement(By.xpath("//*[@content-desc='Hello. Sign in']"));

}

使用上面的代码,我可以安装亚马逊应用程序,也可以打开该应用程序,但是单击登录选项的最后一行没有被单击,我尝试了很多方法来做到这一点。请帮助我。

最佳答案

在所需功能而不是登录 Activity 下,请使用启动 Activity ,您需要更改以下行代码中的 Activity :

capabilities.setCapability("appActivity","com.amazon.mShop.sso.SigninPromptActivity")

关于java - 能够安装亚马逊应用程序但无法打开它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40293247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com