【发布时间】:2018-04-15 00:08:11
【问题描述】:
我使用 Python(在 PyCharm 编辑器中)创建了简单的测试用例,它应该点击 iOS 应用程序上的加入/登录按钮,但它不起作用。代码如下:
from appium import webdriver
import unittest
import os
class LoginTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = '11.0'
desired_caps['deviceName'] = 'iPhone Simulator' # Run on simulator
desired_caps['bundleId'] = 'com.matchbook.MatchbookApp'
desired_caps['app'] = os.path.abspath('/Users/majdukovic/Library/Developer/Xcode/DerivedData/MatchBook-bgvchkbwrithuaegnjgpoffewdag/Build/Products/Debug-iphonesimulator/MatchBook.app') # Path to .app
self.wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps)
self.wd.implicitly_wait(60)
loginButton = self.wd.find_element_by_id("JOIN/LOGIN") # Button ID
self.assertTrue(loginButton.is_displayed())
loginButton.click()
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(LoginTests)
unittest.TextTestRunner(verbosity=2).run(suite)
如果我运行这个测试用例,它会返回: "在 0.000 秒内运行 0 次测试
好的”
Appium 服务器已经在运行并且应用已经打开。在 PyCharm Preferences 中,我选择了 py.test 作为默认测试运行器。
我的设置详情:
macOS - HighSierra v10.13
Appium 桌面应用程序 - v1.2.6
Python - v2.7.10
xCode - v9.0.1
模拟器 - iPhone 8, iOS v11.0
【问题讨论】:
-
你得到的错误是什么?
-
所以,就像什么都没发生一样。我运行我的测试,这是我收到的消息:“”在 0.000 秒内运行 0 次测试“”。我在 appium 日志中看不到任何内容或单击该按钮,就像这段代码什么都不做,我不确定是否应该在 PyCharm 中设置任何偏好或代码不好。
标签: python ios pycharm appium appium-ios