步骤:
1、执行 java -jar selenium-server-standalone-3.141.59.jar -role hub 成功
2、修改node1.json
{
“capabilities”:
[
{
“browserName”: “”,
“version”:“6.0”,
“maxInstances”: 1,
“platform”:“ANDROID”
}
],
“configuration”:
{
“cleanUpCycle”:2000,
“timeout”:30000,
“proxy”: “org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,
“url”:“http://localhost:4723/wd/hub”,
“host”: “localhost”,
“port”: 4723,
“maxSession”: 1,
“register”: true,
“registerCycle”: 5000,
“hubPort”: 4444,
“hubHost”: “192.168.247.1”,
“hubProtocol”: “http”
}
}
3、执行 appium --nodeconfig node1.json 成功
4、执行代码:
from time import sleep
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
class TestXueqiu:
def setup(self):
print("setup")
caps = {}
caps['deviceName'] = 'hogwards'
caps['platformName'] = 'Android'
caps['platformVersion'] = '6.0'
caps['appPackage'] = "com.xueqiu.android"
caps['appActivity'] = ".view.WelcomeActivityAlias"
caps['noReset'] = 'true'
# 之前常规的写法
# self.driver = webdriver.Remote('http://localhost:4723/wd/hub', caps)
# 添加hub功能后的写法, cmd 执行命令 java -jar .\selenium-server-standalone-3.141.59.jar 获得的 Clients should connect to http://192.168.247.1:4444/wd/hub
self.driver = webdriver.Remote('http://192.168.247.1:4444/wd/hub', caps)
self.driver.implicitly_wait(10)
def teardown(self):
print("teardown")
self.driver.quit()
def test_search(self):
print("到底是什么问题呢")
self.driver.find_element(MobileBy.ID, 'com.xueqiu.android:id/tv_search').click()
self.driver.find_element(MobileBy.ID, 'com.xueqiu.android:id/search_input_text').send_keys('alibaba')
5、可以调用起app, app启动后,就马上报错