[英]Appium : how to check device name using automation test cases in java
I am implementing automation test cases for one application.我正在为一个应用程序实施自动化测试用例。 I wanted to generalized some test cases in order to run on each and every device based on some condition.
我想概括一些测试用例,以便根据某些条件在每台设备上运行。 So, in order to do that I have to get device name using some code.
所以,为了做到这一点,我必须使用一些代码来获取设备名称。 I am not able to get code for checking device name.
我无法获取用于检查设备名称的代码。 Any help is most welcome!!!
欢迎任何帮助!!!
While setting appium capabilities, you must be setting device name as well. 设置appium功能时,您还必须设置设备名称。 You can use the same one
你可以使用同一个
Try session details to get connected device name
or udid
尝试会话详细信息以获取连接的设备
name
或udid
String connectedDeviceName = driver.getSessionDetail("deviceName").toString();
String connectedDeviceUdid = driver.getSessionDetail("deviceUDID").toString();
What you can do is use multiple devices to run automation tests on, in that way you can give a specific device udid to a specific class containing your test cases and those test cases will run on only that device. 您可以使用多个设备来运行自动化测试,这样您就可以将特定设备udid提供给包含测试用例的特定类,并且这些测试用例仅在该设备上运行。
Moreover, you can use Annotations using TestNG eg @Beforesuite. 此外,您可以使用TestNG使用注释,例如@Beforesuite。 This will run a specific class only, so only a limited test cases will run.
这将仅运行一个特定的类,因此只运行有限的测试用例。
You can use any of the following methods to get device udid . 您可以使用以下任何方法来获取设备udid 。 All the following method will give the same output.
以下所有方法都将提供相同的输出。
driver.getSessionDetail("deviceName");
driver.getSessionDetail("udid");
driver.getSessionDetail("deviceUDID");
driver.getCapabilities().getCapability("deviceName");
driver.getCapabilities().getCapability("udid");
driver.getCapabilities().getCapability("deviceUDID");
You can use device udid instead of device name
您可以使用设备udid而不是设备名称
[Solution Works only on Android devices]In Order to identify your devices connected to the system, [解决方案仅适用于 Android 设备]为了识别您连接到系统的设备,
adb devices
it will give list of devices connected at present time.它将给出当前连接的设备列表。 [Implementation]
[执行]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.