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
使用复用浏览器技术获取企业微信的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()