sws_kp operation (selenium webdriver + python)

code show as below:

1  # lead pack 
2  from the Selenium Import   webdriver
 3  from Time Import SLEEP
 4  # select the Google browser to open Office website 
5 Driver = webdriver.Chrome ()
 6 url = " https://sws.nbhtxx.com.cn/ " 
7  driver.get (URL)
 . 8  # window is maximized 
. 9  driver.maximize_window ()
 10  # select the user name box, enter a user name the XXXXXXXX 
. 11 driver.find_element_by_xpath ( ' // iNPUT [@ name = "the userid"] ' ) .send_keys ( " XXXXXXXX ")
 12  # selection box password, the password the XXXXXXXX 
13 is driver.find_element_by_xpath ( ' // INPUT [@ name = "password"] ' ) .send_keys ( " the XXXXXXXX " )
 14  # clicks the login button 
15 driver.find_element_by_xpath ( ' // Button [@ class = "btn-the Login"] ' ) .click ()
 16  # login pause one second 
17 SLEEP (1 )
 18  # click the button to the left of bill management 
19 driver.find_element_by_xpath ( ' // ul [@ class = "layui Tree-NAV-layui -nav "] / Li [. 3] ' ) .click ()
 20 is  #Click the document management button under the bill management level 
21 driver.find_element_by_xpath ( ' //a[@data-url="/home/bill/ndjgl.html "] ' ) .click ()
 22  # pause one second, to enter the iframe page 
23 is SLEEP (. 1 )
 24  # iframes = driver.find_element_by_xpath ( '// * [@ ID = "top_tabs_box"] / div / div [. 3] / iframes') 
25 driver.switch_to.frame (driver.find_element_by_xpath ( ' // iframe [the contains (@src, "/ Home / Bill / ndjgl")] ' ))
 26  # pause one second, click on the Add button in the iframe page 
27 SLEEP (1 )
 28 driver.find_element_by_xpath ( ' // * [@ class = "layui-btn-group "]/button[2]') .click ()
 29  # to exit to the outside, and then into the second iframes 
30  driver.switch_to.default_content ()
 31 is  # tangential to the first iframes 
32 SLEEP (. 1 )
 33 is driver.switch_to.frame (driver.find_element_by_xpath ( ' iframes // [the contains (@src, "/ Home / Bill / ndjgl")] ' ))
 34 is  # tangential to the second iframes 
35 SLEEP (. 1 )
 36 driver.switch_to.frame (driver.find_element_by_xpath ( ' // iframes [the contains (@src, "the Add-djdr")] ' ))
 37 [  # button click the name of the right side pin 
38 is SLEEP (. 1 )
 39 driver.find_element_by_xpath('//*[@id="lzkp-box"]/tbody/tr/td[2]/table/tbody/tr[1]/td/table/tfoot/tr[1]/td[1]/i').click()
40 #获取销方信息的弹窗,从最外面切进去3层iframe
41 driver.switch_to.default_content()
42 driver.switch_to.frame(driver.find_element_by_xpath('//iframe[contains(@src,"/home/bill/ndjgl")]'))
43 sleep(1)
44 driver.switch_to.frame(driver.find_element_by_xpath('//iframe[contains(@src,"djdr-add")]'))
45 sleep(1)
46 driver.switch_to.frame(driver.find_element_by_xpath(' // iframes [the contains (@src, "xfxx")] ' ))
 47  # pin party information input text box pop "the TEST" 
48 driver.find_element_by_xpath ( ' // * [@ ID = "name"] ' ) .send_keys ( " TEST " )
 49  # click the search button to find the simple code of corporate TEST 
50 SLEEP (1 )
 51 driver.find_element_by_xpath ( ' // the button [@ class = "layui-btn Search"] ' ). the click ()
 52  # click simplified business tax ID code TEST 
53 SLEEP (1 )
 54 driver.find_element_by_xpath ( ' // * [@ class = "layui-table"]/tbody/tr[1]/td[2]' ) .Click ()
 55  # fall back to fill open invoice interface, i.e. information on the pin side of a pop iframe page 
56  # There are two ways to cut: 1 from the two outermost cut into; 2 from pin party information iframe fallback invoice up to fill open an iframe 
57  driver.switch_to.parent_frame ()
 58  # later returned to fill open invoice page, click on the name of the purchaser rightmost button 
59 SLEEP (1 )
 60 driver.find_element_by_xpath ( ' // * [@ ID = "lzkp-Box"] / tbody / TR / TD [2] / Table / tbody / TR [. 1] / TD / Table / thead / TR [. 1] / TD [. 1] / I ' ) .click ()
 61 is  # at this time the pop-up window purchaser information iframes 
62 is  # we already fill open invoice second iframe, just need to cut one. 
63 is driver.switch_to.frame (driver.find_element_by_xpath ( ' // iframes [the contains (@src, "gfxx")]' ))
 64  # after the cut to the purchase information iframe, select the input box, enter the customer name: Wang Zhaojun 
65 SLEEP (1 )
 66 driver.find_element_by_xpath ( ' // * [@ the above mentioned id = "name"] ' ) .send_keys ( " Wang Zhaojun " )
 67  # click on the search button, to search the customer name is Wang Zhaojun business 
68 driver.find_element_by_xpath ( ' // the button [@ class = "layui-btn Search"] ' ) .click ()
 69  # click to customers 91330200573697175C heading for the enterprise 
70 SLEEP (. 1 )
 71 is driver.find_element_by_xpath ( ' // * [@ class = "Table-layui"] / tbody / TR [. 1] / TD [2] ').click()
72  # returned to fill open invoices interface, which is the second iframe page, so the name of the purchaser from the pop iframe fallback 
73  driver.switch_to.parent_frame ()
 74  # This will fall back iframe billing page, you can direct operating elements on the page, click on the Actions column: goods or taxable services button, to the right of the service name 
75 SLEEP (1 )
 76 driver.find_element_by_xpath ( ' // * [@ the above mentioned id = "tr0"] / td [1] / I ' ) .click ()
 77  # then pop the product information window is iframe layer, from the need to cut iframe billing information into the second layer 
78 SLEEP (. 1 )
 79 driver.switch_to.frame (driver.find_element_by_xpath ( ' // iframes [the contains (@src, "goods")] ' ))
 80  # cut into the commodity information iframe, enter the box under the trade name: No. 11 slow Goat 
81driver.find_element_by_xpath ( ' // * [@ the above mentioned id = "name"] ' ) .send_keys ( " No. 11 Slow Goat " )
 82  # click on the search button, to search the trade name 11 slow Frankie merchandise 
83 Driver. find_element_by_xpath ( ' // the Button [@ class = "layui-btn Search"] ' ) .click ()
 84  # after this handsome selected commodities, click on it to determine the tax classification and coding of this product 
85 SLEEP (1 )
 86 Driver .find_element_by_xpath ( ' // * [@ class = "Table-layui"] / tbody / TR / TD [2] / div ' ) .click ()
 87  # to return to the page billing iframe, enter in the remarks column: ha It is so powerful! 
88  driver.switch_to.
SLEEP (1 )
 90 driver.find_element_by_xpath ( ' // * [@ the above mentioned id = "bz"] ' ) .send_keys ( " ! Life is short, I use Python " )
 91  # Select the number box enter: 10 
92 driver.find_element_by_xpath ( ' // * [@ ID = "spsl_0"] ' ) .send_keys ( " 10 " )
 93  # click amount (tax) block 
94 driver.find_element_by_xpath ( ' // * [@ ID = "je_0"] ' ). the click ()
 95  # click the billing button 
96 driver.find_element_by_xpath ( '* // [@ class = "inline layui-pull-right"] / the Button [7] ' ) .click ()
 97  # to this firm billing integration script finished, thanks to CCTV ~

 

Guess you like

Origin www.cnblogs.com/chenshengkai/p/11298005.html