AttributeError:「WebDriver」オブジェクトにappiumで検出された属性「contexts」がありません

私の元のコードは次のとおりです。

from selenium import webdriver
import os, time, unittest

# 初始化cap
desired_caps = {
            'app':'',
            'platformName': 'Android',
            'platformVersion':'7.1.1',
            'deviceName': 'c353ce90',
            'fastReset': 'false',
            'fullReset': 'false',
            'noReset': 'True',
            'automationName':'appium',
            'appPackage': 'com.tencent.mm',
            'appActivity': '.ui.LauncherUI',
            'unicodeKeyboard': 'True',
            'resetKeyboard': 'True',
            'chromeOptions': {
                'androidProcess': 'com.tencent.mm:appbrand0'
            }
 }
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

# 打开微信-->发现-->小程序-->美团外卖

time.sleep(5)
print('点击发现')
driver.find_element_by_xpath("//*[@text='发现']").click()
time.sleep(2)
print('点击小程序')
driver.find_element_by_xpath("//*[@text='小程序']").click()
print(driver.context)

time.sleep(2)
print('点击美团外卖')
driver.find_element_by_xpath("//*[@text='美团外卖']").click()
print('okokokkkkkkkkk')

# driver.switch_to.context('WEBVIEW_com.tencent.mm:tools')

ランタイムエラーAttributeError:「WebDriver」オブジェクトに属性「contexts」がありません

たくさんの解決策を見つけましたが、解決しませんでした。それから、質問と回答を見ました。

解決策は次のとおりです。

from selenium import webdriver

from appium import webdriver

もう一度実行してください

 

おすすめ

転載: blog.csdn.net/dream_18/article/details/85137580