• 新浪微博超话题签到demo


    # Generated by Selenium IDE
    import pytest
    import time
    import json
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.support import expected_conditions
    from selenium.webdriver.support.wait import WebDriverWait
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    
    class TestUntitled():
      def setup_method(self, method):
        self.driver = webdriver.Chrome()
        self.vars = {}
      
      def teardown_method(self, method):
        self.driver.quit()
      
      def wait_for_window(self, timeout = 2):
        time.sleep(round(timeout / 1000))
        wh_now = self.driver.window_handles
        wh_then = self.vars["window_handles"]
        if len(wh_now) > len(wh_then):
          return set(wh_now).difference(set(wh_then)).pop()
      
      def test_untitled(self):
        self.driver.get("https://weibo.com/u/5300304405")
        self.driver.set_window_size(1900, 1020)
        self.driver.execute_script("window.scrollTo(0,293)")
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(3) .clb").click()
        self.vars["win7892"] = self.wait_for_window(2000)
        self.vars["root"] = self.driver.current_window_handle
        self.driver.switch_to.window(self.vars["win7892"])
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.execute_script("window.scrollTo(0,451)")
        self.driver.find_element(By.CSS_SELECTOR, ".Frame_wrap_3g67Q").click()
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.LINK_TEXT, "赵文卓超话").click()
        self.vars["win4100"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win4100"])
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.execute_script("window.scrollTo(0,264)")
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) .wbpro-iconbed:nth-child(3) > .woo-font").click()
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(1) .cla").click()
        self.vars["win2110"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win2110"])
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.switch_to.window(self.vars["root"])
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(2) .item").click()
        self.vars["win8760"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win8760"])
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.switch_to.window(self.vars["root"])
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(3) .cla").click()
        self.vars["win2723"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win2723"])
        element = self.driver.find_element(By.CSS_SELECTOR, ".fixed_width")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.execute_script("window.scrollTo(0,450)")
        self.driver.execute_script("window.scrollTo(0,607)")
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) .wbpro-iconbed:nth-child(3) > .woo-font").click()
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(1) .clb").click()
        self.vars["win5872"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win5872"])
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_c").click()
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        self.driver.find_element(By.CSS_SELECTOR, ".W_layer_close > .W_ficon").click()
        self.driver.close()
        self.driver.switch_to.window(self.vars["root"])
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(2) .con").click()
        self.vars["win3149"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win3149"])
        element = self.driver.find_element(By.LINK_TEXT, "签到")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        element = self.driver.find_element(By.CSS_SELECTOR, "body")
        actions = ActionChains(self.driver)
        actions.move_to_element(element, 0, 0).perform()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.close()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.execute_script("window.scrollTo(0,906)")
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(3) .item").click()
        self.vars["win1285"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win1285"])
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        element = self.driver.find_element(By.LINK_TEXT, "签到")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        element = self.driver.find_element(By.CSS_SELECTOR, "body")
        actions = ActionChains(self.driver)
        actions.move_to_element(element, 0, 0).perform()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.close()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) .wbpro-iconbed:nth-child(3) > .woo-font").click()
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) .wbpro-iconbed:nth-child(1) > .woo-font").click()
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) .wbpro-iconbed:nth-child(1) > .woo-font").click()
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) .wbpro-iconbed:nth-child(1) > .woo-font").click()
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(1) .item").click()
        self.vars["win6392"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win6392"])
        self.driver.find_element(By.LINK_TEXT, "签到").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.close()
        self.driver.switch_to.window(self.vars["root"])
        element = self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(2) .clb")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).click_and_hold().perform()
        element = self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(2) .clb")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        element = self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(2) .clb")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).release().perform()
        self.driver.find_element(By.CSS_SELECTOR, "div:nth-child(5) > .wbpro-side > div:nth-child(2)").click()
        self.vars["window_handles"] = self.driver.window_handles
        self.driver.find_element(By.CSS_SELECTOR, ".wbpro-side-card4:nth-child(2) .clb").click()
        self.vars["win3518"] = self.wait_for_window(2000)
        self.driver.switch_to.window(self.vars["win3518"])
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span").click()
        element = self.driver.find_element(By.CSS_SELECTOR, ".W_btn_b > span")
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.driver.close()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.switch_to.window(self.vars["win2723"])
        self.driver.close()
        self.driver.switch_to.window(self.vars["win8760"])
        self.driver.close()
        self.driver.switch_to.window(self.vars["win2110"])
        self.driver.close()
        self.driver.switch_to.window(self.vars["win4100"])
        self.driver.close()
        self.driver.switch_to.window(self.vars["win7892"])
        self.driver.close()
        self.driver.switch_to.window(self.vars["root"])
        self.driver.close()
      
    

      

    不求最好,但求更好!态度决定一切!
  • 相关阅读:
    web窗体asp:Repeater循环绑定
    Exception:No data is available for encoding 936
    GFL: Generalized Focal Loss
    Stitcher: Feedbackdriven Data Provider for Object Detection
    C++ 动态伸缩线程池
    docker pull 配置代理
    docker 配置国内镜像地址
    关于Chrome浏览器http链接跳转成https的问题
    CentOS 防火墙入门
    两个整数相除得得到结果百分比【我】
  • 原文地址:https://www.cnblogs.com/zhaoyiguang/p/14758912.html
Copyright © 2020-2023  润新知