Get Element Location關鍵字用來獲取一個Element的Location位置,該關鍵字接收一個參數[ locator ]
示例1:使用Get Element Location來獲取一個EditText輸入框的Location位置,在這里依舊采用上面使用的APP界面來做操作示例
Open Application http://localhost:4723/wd/hub platformName=Android platformVersion=22 deviceName=98YFBP522VSU app=C:/Users/yongqing/Desktop/app-debug.apk appPackage=com.example.calculator appActivity=MainActivity
${Location} Get Element Location id=com.example.calculator:id/factorone
log ${Location}
執行結果:
Starting test: RobotFrameworkTest1.TestSuite5.TestCase010
20170510 15:56:05.348 : INFO : msg:find id=com.example.calculator:id/factorone
20170510 15:56:06.929 : INFO : Element 'id=com.example.calculator:id/factorone' location: {'y': 50, 'x': 0}
20170510 15:56:06.930 : INFO : ${Location} = {'y': 50, 'x': 0}
20170510 15:56:06.932 : INFO : {'y': 50, 'x': 0}
Ending test: RobotFrameworkTest1.TestSuite5.TestCase010
從執行結果可以看到,獲取到的Location結果為{'y': 50, 'x': 0}
【原文歸作者所有,歡迎轉載,但是保留版權】