为什么Appium会停止在React Native Android应用程序中查找元素?

时间:2018-09-28 10:26:58

标签: java selenium react-native appium appium-android

我有一个具有本机可访问性ID的react本机应用程序,并且我正在使用具有该可访问性ID的XPath。但是,当我运行代码时,appium停止寻找元素,它没有前进,没有给出任何异常,我确信这不是同步问题。我尝试了其他应用。它的工作正常。仅与此应用程序一起,它正在发生。我将分享我的代码和元素。

import java.net.URL;
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.BeforeTest;
import org.testng.annotations.Test;
import io.appium.java_client.android.AndroidDriver;

public class BlackLotus{
    static AndroidDriver driver;

    @BeforeTest
    public void setupAppium() throws Exception {

        DesiredCapabilities capabilities = new DesiredCapabilities();


        String devicename= Launch.devicename();
        capabilities.setCapability("deviceName", devicename);
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability(CapabilityType.VERSION, "8.0");
        capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("appPackage","com.rt.pinprickeffect.meditation.staging");d 
        capabilities.setCapability("appActivity", "com.rt.pinprickeffect.meditation.MainActivity");
        driver = new AndroidDriver(new    URL("http://127.0.0.1:5556/wd/hub"), capabilities);
}
        @Test
        public void Playdevotion() throws InterruptedException
        {
            Thread.sleep(15000);
            WebElement ele = driver.findElement(By.xpath("//android.view.ViewGroup[@content-desc=\"MeditateWithOthersButton\"]"));
            //driver.findElement)
            Thread.sleep(2000);
            ele.click();

        }

在appium中,查找元素的过程正在停止。您可以在下面看到鸦皮日志。

[HTTP] --> POST /wd/hub/session/c6520f2b-ca79-4fc0-a555-3fbee6bc15ee/element [HTTP] {"using":"xpath","value":"//android.view.ViewGroup[@content-desc=\"MeditateWithOthersButton\"]"} 

[MJSONWP] Calling AppiumDriver.findElement() with args: ["xpath","//android.view.ViewGroup[@content-desc=\"MeditateWithOthersButton\"]","c6520f2b-ca79-4fc0-a555-3fbee6bc15ee"] 

[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator [BaseDriver] Waiting up to 0 ms for condition 

[AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.ViewGroup[@content-desc=\"MeditateWithOthersButton\"]","context":"","multiple":false}} 

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.view.ViewGroup[@content-desc=\"MeditateWithOthersButton\"]","context":"","multiple":false}} 

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION 


[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find 

[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding '//android.view.ViewGroup[@content-desc="MeditateWithOthersButton"]' using 'XPATH' with the contextId: '' multiple: false

在此之后,将完全没有日志,并且执行也停留在这里。仅适用于我正在使用的应用程序。其他人都很好。

有人可以帮忙吗?如果对问题有疑问,请发表评论。

这是来自旁观者

<android.widget.FrameLayout>
<android.widget.LinearLayout>
<android.widget.FrameLayout resource-id="android:id/content">
<android.widget.FrameLayout>
<android.view.ViewGroup>
<android.view.ViewGroup>
<android.support.v4.widget.DrawerLayout>
<android.view.ViewGroup>
<android.view.ViewGroup>
<android.view.ViewGroup>
<android.view.ViewGroup>
<android.view.ViewGroup>
<android.view.View>
<android.view.ViewGroup content-desc="MeditateWithOthersButton">
<android.widget.ImageView>
<android.widget.TextView>
<android.view.ViewGroup content-desc="MeditateWithNowButton">
<android.widget.TextView>
<android.view.ViewGroup>
<android.view.ViewGroup>
<android.view.View resource-id="android:id/statusBarBackground">
<android.view.View resource-id="android:id/navigationBarBackground">

0 个答案:

没有答案