zoukankan      html  css  js  c++  java
  • 破码之拖动滑块

    #破码之拖动滑块
    # encoding:utf-8
    import selenium
    import time
    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver import ActionChains
    
    driver = webdriver.Chrome()
    # 设定等待时间
    wait = WebDriverWait(driver, 30)
    # 打开网页
    driver.get("http://……")
    
    #等待搜索框加载完成传入搜索关键字
    input = wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="searchText"]')))
    input.send_keys(u"安徽投资有限责任公司")
    time.sleep(5)
    #等待搜索按钮可点击,点击
    button = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="click"]')))
    button.click()
    time.sleep(5)
    actions = ActionChains(driver)
    # 进入搜索页后,找到滑块
    element = driver.find_element_by_xpath("//div[@class='gt_slider_knob gt_show']")
    
    #鼠标点击元素并按住不放
    actions.click_and_hold(on_element = element).perform()
    
    #拖动鼠标到指定的位置,注意这里位置是相对于元素左上角的相对值
    actions.move_to_element_with_offset(to_element = element, xoffset=200, yoffset = 50).perform()
    # actions.move_to_element(to_element = element).perform()
    
    #释放鼠标
    actions.release(on_element = element).perform()
    time.sleep(3)
  • 相关阅读:
    [LeetCode 题解]: Triangle
    [LeetCode 题解]: pow(x,n)
    [LeetCode 题解]: plusOne
    [LeetCode 题解]: ZigZag Conversion
    error: field 'b' has imcomplete type
    两个分数的最小公倍数
    DDR工作原理
    流水线技术原理和Verilog HDL实现
    FPGA主要应用
    提高器件工作的速度
  • 原文地址:https://www.cnblogs.com/themost/p/7389983.html
Copyright © 2011-2022 走看看