Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/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 3.x webdriver移动仿真python中的向下滑动功能_Python 3.x_Webdriver_Selenium Chromedriver_Simulation - Fatal编程技术网

Python 3.x webdriver移动仿真python中的向下滑动功能

Python 3.x webdriver移动仿真python中的向下滑动功能,python-3.x,webdriver,selenium-chromedriver,simulation,Python 3.x,Webdriver,Selenium Chromedriver,Simulation,我正在尝试在使用python的webdriver移动仿真中使用“向下滑动以刷新”功能。我找到了两个元素的位置,并尝试在后一个位置点击、按住和释放。对于这两个元素,在手机上滑动可以正常工作。这是我的密码。甚至有可能复制移动行为到这种程度吗 options = uc.ChromeOptions() deviceMetrics = { "width":480, "height":854, "pix

我正在尝试在使用python的webdriver移动仿真中使用“向下滑动以刷新”功能。我找到了两个元素的位置,并尝试在后一个位置点击、按住和释放。对于这两个元素,在手机上滑动可以正常工作。这是我的密码。甚至有可能复制移动行为到这种程度吗

options = uc.ChromeOptions()
    deviceMetrics = {
        "width":480,
        "height":854,
        "pixelRatio":3.0
        }
    mobile_emulation = {
                # "userAgent": 'Mozilla/5.0 (Linux; Android 4.0.3; HTC One X Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19',
                "deviceMetrics":deviceMetrics,
                "userAgent":"Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL Build/OPD1.170816.004) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/67.0.3396.99 Mobile Safari/537.36"
            }
    options.add_experimental_option("mobileEmulation", mobile_emulation)
    options.add_experimental_option('w3c', False)
    # # options.add_argument("--headless")
    
    browser = uc.Chrome(options = options)
    browser.set_window_position(0, 0)
    browser.set_window_size(470,854)
    
    
    browser.get("http://google.com")
    action = TouchActions(browser)
    elem = browser.find_element_by_class_name("igu8Pb")
    elem2 = browser.find_element_by_id("hplogo")
    print(elem2.location) #{'x': 160, 'y': 112}
    print(elem.location) #{'x': 175, 'y': 0}
    action.tap_and_hold(175, 0)
    action.release(160, 112)
    action.perform()

这是我找到的最接近的链接,但不幸的是不是在python中。这是我找到的最接近的链接,但不幸的是不是在python中。