web logs blog optimized version

Before the introduction of an article on the browser to log blog park, for users not yet opened the blog, Baidu from the beginning to the end of the park to log blog, complicated steps, but simple, today to introduce an optimized version of the automatic sign-in method , but this method applies only to a small partner has been opened blog 
method or as positioning elements step by step through the execution, did not talk much, the following code is attached directly to:
1.  from selenium import webdriver
2. from selenium.webdriver.support.wait import WebDriverWait
3. from selenium.webdriver.support import expected_conditions as ec
4. a=webdriver.Chrome()
5. a.get("https://account.cnblogs.com/signin")
6. a.implicitly_wait(10)
7. w=WebDriverWait(a,6,0.2)
8. a.maximize_window()
9. w.until(ec.visibility_of_element_located(("id","LoginName"))).send_keys("用户名")
10. w.until(ec.visibility_of_element_located(("id","Password"))).send_keys("密码")
11. w.until(ec.visibility_of_element_located(("id","IsRemember"))).click()
12. w.until(ec.visibility_of_element_located(("xpath",'//*[@id="submitBtn"]/span[1]'))).click()
Code analysis: 
    Step introduction Google browser driver
    steps 2, 3 and ec introducing explicit wait module, for positioning the main elements of
    step 4 starts driving Google
    Step 5 Go to user login page
    step sequentially sets recessive wait 6-8 dominant and wait for the page to maximize the
    steps 9-10 positioning input box and enter the user name and password
    step 11 locate and click the check box to remember the password, do not want to save the password can remove a small partner Ha
    step 12 is located and click the login button

control these methods are little friends can try to log on to other interfaces, such as QQ space, there will be used in the framework of operation of a switch, the next time to introduce you how to play

Guess you like

Origin www.cnblogs.com/szwlycw/p/11564508.html