Python 多个chromedriver实例android
我的代码如下所示Python 多个chromedriver实例android,python,selenium,selenium-webdriver,selenium-chromedriver,Python,Selenium,Selenium Webdriver,Selenium Chromedriver,我的代码如下所示 def _launch_android(): log.info("launching chrome on android device") capabilities = { 'chromeOptions': { 'androidPackage': 'com.android.chrome', } } log.info("Verifying that android device is conn
def _launch_android():
log.info("launching chrome on android device")
capabilities = {
'chromeOptions': {
'androidPackage': 'com.android.chrome',
}
}
log.info("Verifying that android device is connected via USB")
subprocess.Popen('adb devices')
p = subprocess.Popen("adb devices", stdout=subprocess.PIPE)
line = p.stdout.readline()
while line:
log.info(line)
if re.match("\S+\s+device", line):
break
line = p.stdout.readline()
else:
raise AssertionError, "Device not connected via USB"
driver = webdriver.Chrome(desired_capabilities=capabilities)
return driver
现在,这段代码的问题是,当我启动第二个实例时,第一个实例关闭,我无法对其执行任何操作。
e、 g
这里
b.get
起作用,但a.get
不起作用。chromedriver由selenium自动启动,只要您创建一个webdriver.Chrome()实例即可。。。。我不确定你到底想用那段代码做什么。@CoreyGoldberg我刚刚举了这里提到的例子,但是webdriver.Chrome()也可以,但这并不能解决我的问题。我仍然有同样的问题
a =_launch_android()
b = _launch_android()
a.get("https://www.google.com")
b.get("https://www.facebook.com")