20230108 web 实战训练营

PPT

代码地址

课后调查表

https://jinshuju.net/f/vYLyM1

页面暂停

mock 数据 Faker

知识点回顾-xmind思维导图

2023Selenium 框架.xmind (213.0 KB)

from time import sleep

import yaml
from selenium import webdriver


class TestCookieLogin:
    def setup_class(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(3)

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

    def test_get_cookies(self):
        self.driver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
        sleep(20)
        cookies = self.driver.get_cookies()
        with open("cookie.yaml","w") as f:
            yaml.safe_dump(cookies,f)

    def test_add_cookies(self):
        self.driver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")
        cookies = yaml.safe_load(open("cookie.yaml"))
        for c in cookies:
            self.driver.add_cookie(c)
        self.driver.get("https://work.weixin.qq.com/wework_admin/loginpage_wx")





1 Like
关闭