【selenium实战1】selenium企业微信实战1

作业地址

page:
https://github.com/mengqiD11/selenium_3/blob/master/page/base_page.py
https://github.com/mengqiD11/selenium_3/blob/master/page/add_member.py
https://github.com/mengqiD11/selenium_3/blob/master/page/index.py
testcases:
https://github.com/mengqiD11/selenium_3/blob/master/testcase/test_add_member.py

作业地址

作业:https://github.com/606keng/weeds_study/blob/master/selenium_study/qiyeweixin/test_cookies.py

https://github.com/tim8709/hogwarts_testing/blob/master/web/debug_and_cookies.py

https://github.com/Ashley-luo66/hogwarts_lagou_homework/tree/master/selenium_homework/selenium_1

使用复用浏览器技术获取企业微信的cookie,点击添加成员

class Test_debug():
    def setup_method(self):
        #使用网页复用
        chrome_opts=webdriver.ChromeOptions()
        chrome_opts.debugger_address="127.0.0.1:9222"
        self.driver = webdriver.Chrome(options=chrome_opts)
        self.driver.implicitly_wait(3)

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

    def test_1(self):
        #获得cookies
        cookies=self.driver.get_cookies()
        with open("cookies.txt", 'w') as f:
             json.dump(cookies, f)
        with open("cookies.txt", "r") as f:
            cookies:List[Dict]=json.load(f)
        for cookie in cookies:
            if "expiry" in cookie.keys():
                cookie.pop("expiry")
            self.driver.add_cookie(cookie)
        #点击添加成员
        self.driver.find_element(By.CSS_SELECTOR,'.index_service_cnt_itemWrap:nth-child(1)').click()

https://github.com/hehe1523233/selenium
github 地址