Локально протестировано с OnePlus 3T, и оно прошло успешно
Возможности:
capabilities.setCapability("app", "C:\\Users\\james\\Desktop\\stackoverflow\\question_50172058_unable-to-open-and-close-notifications-panel-with-aws-device-farm\\testofopenNotifications\\app-debug.apk");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "OnePlus");
Версия Appium: 1.7.1
Выход сервера Appium:
[info] [HTTP] --> POST /wd/hub/session/51cf9f0e-2106-4e34-b0d5-7df3caebc223/appium/device/open_notifications {}
[debug] [MJSONWP] Calling AppiumDriver.openNotifications() with args: ["51cf9f0e-2106-4e34-b0d5-7df3caebc223"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"openNotification","params":{}}[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.openNotifications() result: true
[info] [HTTP] <-- POST /wd/hub/session/51cf9f0e-2106-4e34-b0d5-7df3caebc223/appium/device/open_notifications 200 328 ms - 76
После упаковки тестов с использованием сборки и pom из примера тестов с помощью команды mvn clean package -DskipTests=true
это результат фермы устройств с использованием Moto G4 Android 7:
Версия сервера Appium: 1.7.1
Использовал пустой объект требуемых возможностей, как описано здесь
успешно и открывает уведомления. Смотрите видео
Журналы сервера Appium:
2018-05-05 16:55:06:839 - [HTTP] --> POST /wd/hub/session/c70b3b24-b7d6-4c6b-a7e2-d4ff5e91aa22/appium/device/open_notifications {}
2018-05-05 16:55:06:868 - [debug] [MJSONWP] Calling AppiumDriver.openNotifications() with args: ["c70b3b24-b7d6-4c6b-a7e2-d4ff5e91aa22"]
2018-05-05 16:55:06:872 - [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"openNotification","params":{}}
2018-05-05 16:55:06:888 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"openNotification","params":{}}
2018-05-05 16:55:06:889 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
2018-05-05 16:55:06:890 - [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: openNotification
2018-05-05 16:55:06:891 - [debug] [AndroidBootstrap] Received command result from bootstrap
2018-05-05 16:55:06:893 - [debug] [MJSONWP] Responding to client with driver.openNotifications() result: true
2018-05-05 16:55:06:907 - [HTTP] <-- POST /wd/hub/session/c70b3b24-b7d6-4c6b-a7e2-d4ff5e91aa22/appium/device/open_notifications 200 55 ms - 76
Вот метод испытания, который я выполнил:
@Test public void testOpenNotifications(){
//docs: https://github.com/appium/appium/blob/62700d3b1dc0edd985502cc1279747a782f3ee74/docs/en/commands/device/system/open-notifications.md
driver.openNotifications();
}
Я думал, что код, вызывающий sleep, может вызывать проблему, но, похоже, это работает. см видео
код:
@Test public void testOpenNotificationsWithSleep() throws InterruptedException{
TimeUnit.SECONDS.sleep(3);
driver.openNotifications();
TimeUnit.SECONDS.sleep(3);
}
Не могли бы вы поделиться журналами вашего сервера appium с момента выполнения в Device Farm? Он покажет ответ от UIAutomator или UIAutomator2, и мы можем пойти оттуда.
Вот мой полный тестовый класс для сравнения:
package Tests;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class OpenNotificationsTest{
/**
* Make the driver static. This allows it to be created only once
* and used across all of the test classes.
*/
public static AndroidDriver<MobileElement> driver;
/**
* This method runs before any other method.
*
* Appium follows a client - server model:
* We are setting up our appium client in order to connect to Device Farm's appium server.
*
* We do not need to and SHOULD NOT set our own DesiredCapabilities
* Device Farm creates custom settings at the server level. Setting your own DesiredCapabilities
* will result in unexpected results and failures.
*
* @throws MalformedURLException An exception that occurs when the URL is wrong
*/
@BeforeSuite
public void setUpAppium() throws MalformedURLException {
final String URL_STRING = "http://127.0.0.1:4723/wd/hub";
URL url = new URL(URL_STRING);
//Use a empty DesiredCapabilities object fro device farm
DesiredCapabilities capabilities = new DesiredCapabilities();
//local capabilities
capabilities.setCapability("app", "C:\\Users\\james\\Desktop\\stackoverflow\\question_50172058_unable-to-open-and-close-notifications-panel-with-aws-device-farm\\testofopenNotifications\\app-debug.apk");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "OnePlus");
driver = new AndroidDriver<MobileElement>(url, capabilities);
//Use a higher value if your mobile elements take time to show up
driver.manage().timeouts().implicitlyWait(35, TimeUnit.SECONDS);
}
@Test public void testOpenNotifications(){
//docs: https://github.com/appium/appium/blob/62700d3b1dc0edd985502cc1279747a782f3ee74/docs/en/commands/device/system/open-notifications.md
driver.openNotifications();
}
@Test public void testOpenNotificationsWithSleep() throws InterruptedException{
TimeUnit.SECONDS.sleep(3);
driver.openNotifications();
TimeUnit.SECONDS.sleep(3);
}
/**
* Always remember to quit
*/
@AfterSuite
public void tearDownAppium() {
driver.quit();
}
/**
* Restart the app after every test class to go back to the main
* screen and to reset the behavior
*/
@AfterClass
public void restartApp() {
driver.resetApp();
}
}
Надеюсь услышать от вас скоро.
-Джеймс