Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 多个chromedriver实例android_Python_Selenium_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

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")