selenium---touchAction中遇到的问题

from selenium import webdriver
from selenium.webdriver import TouchActions
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver import ChromeOptions


class TestActionChains():
def setup(self):
option = webdriver.ChromeOptions()
option.add_experimental_option('w3c',False)
self.driver = webdriver.Chrome(options=option)
self.driver.implicitly_wait(5)

def teardown(self):
self.driver.quit()

def test_touchaction(self):

self.driver.get("https://www.baidu.com/")
el = self.driver.find_element(By.ID, "kw")
print("11111111113",type(el))
el_search = self.driver.find_element(By.ID, "su")
el.send_keys("selenium测试")
action = TouchActions(self.driver)
action.tap(el_search)
action.perform()
action.scroll_from_element(el, 0, 10000).perform()
sleep(3)

 

 


在使用touchAction的时候 出现上述截图问题是w3c引起的问题,填下下面内容解决
      option = webdriver.ChromeOptions()
option.add_experimental_option('w3c',False)
会出现W3C的问题,加上之后以为程序可以运行了,结果又出现了以下问题

 

 上述的问题原因是,selenium 4.0 有兼容性问题 ,尝试在chrome option加入add_experimental_option(‘w3c’, True)-->改为Trun之后就又会出现W3C的问题 ,如果不行执行装3.0的版本




posted @ 2022-03-19 18:44  小_糖  阅读(518)  评论(3)    收藏  举报