docker 部署appium

1.docker appium镜像和命令:https://github.com/appium/appium-docker-android

2.启动appium

docker run --privileged -d -p 4723:4723 -v ~/.android:/root/.android -v /dev/bus/usb:/dev/bus/usb --name appium appium/appium

3.docker appium连接设备

adb devices   # 查看windows连接设备
adb connect 127.0.0.1:62001   # 手动连接设备
adb -s 127.0.0.1:62001 tcpip 5555(自己设置的端口号)   # 更改连接方式
docker exec -it appium adb devices   # 查看连接设备
docker exec -it appium adb connect 127.17.100.15(模拟器ip):5555(端口)   # 手动连接设备

4.开启多个appium容器

docker run --privileged -d -p 4723:4723 -v ~/.android:/root/.android -v /dev/bus/usb:/dev/bus/usb --name appium1 appium/appium

docker run --privileged -d -p 4724:4723 -v ~/.android:/root/.android -v /dev/bus/usb:/dev/bus/usb --name appium2 appium/appium

docker run --privileged -d -p 4725:4723 -v ~/.android:/root/.android -v /dev/bus/usb:/dev/bus/usb --name appium3 appium/appium

5.docker appium连接

adb -s 127.0.0.1:62001 tcpip 5555(自己设置的端口号)   # 更改连接方式
docker exec -it appium adb devices   # 查看连接设备
docker exec -it appium adb connect 192.168.31.158(模拟器ip):5555(端口)

adb -s 127.0.0.1:62025 tcpip 5555(自己设置的端口号)   # 更改连接方式
docker exec -it appium adb devices   # 查看连接设备
docker exec -it appium adb connect 192.168.31.173(模拟器ip):5555(端口)

adb -s 127.0.0.1:62026 tcpip 5555(自己设置的端口号)   # 更改连接方式
docker exec -it appium adb devices   # 查看连接设备
docker exec -it appium adb connect 192.168.31.174(模拟器ip):5555(端口)

6.修改代码

from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['deviceName'] = '192.168.31.158(夜神模拟器ip):5555(tcpip转换的端口)'
# desired_caps['deviceName'] = '127.0.0.1:62001'  # 夜神模拟器
# self.desired_caps['deviceName'] = 'MXF5T15C24001273'  # 华为手机
desired_caps['platformVersion'] = '5.1.1'  # 夜神模拟器
# self.desired_caps['platformVersion'] = '6.0'  # 华为手机
desired_caps['appPackage'] = 'cn.rongcloud.kaixinliao'
desired_caps['appActivity'] = 'cn.rongcloud.kaixinliao.ui.activity.SplashActivity'
desired_caps['noReset'] = True
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True

driver = webdriver.Remote('http://192.168.31.111(服务器ip):4723(appium映射的端口号)/wd/hub', desired_caps)

  

  

转载于:https://www.cnblogs.com/yoyo1216/p/11189632.html

你可能感兴趣的:(docker 部署appium)