1. 程式人生 > >企業庫(編輯2)

企業庫(編輯2)

chrom sleep bmi pat win log 打開 自動 chrome

from selenium import webdriver
import time
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.support.ui import Select
import os

driver=webdriver.Chrome()
#登錄
driver.get("https://ftanjian.chinabeacon.cn/Login.html")
driver.set_window_size(1440,900)
now_url=driver.current_url
print(now_url)
time.sleep(2)
driver.find_element_by_id("txt_LoginName").send_keys("shanxiaofang")
driver.find_element_by_id("txt_Password").send_keys("123")
time.sleep(2)
driver.find_element_by_css_selector(".login_btn>button").click()
time.sleep(5)
#企業庫
driver.find_element_by_link_text("企業庫").click()
time.sleep(8)
#查詢新增的企業
driver.find_element_by_id("EnterpriseName").send_keys("自動化測試")
time.sleep(1)
driver.find_element_by_id("btn_search").click()
time.sleep(2)
#選定企業
driver.find_element_by_xpath(".//*[@id=‘enterprise_list‘]/tr[1]/td[4]").click()
time.sleep(1)
#打開編輯企業頁面
driver.find_element_by_id("btn_edit_enterprise").click()
time.sleep(8)
#打開經營信息頁面
driver.find_element_by_link_text("經營信息").click()
time.sleep(8)
#上傳文件
upload=driver.find_element_by_xpath("//*[@id=‘uploadifive-EnterpriseIchnographyPictureId‘]/input[2]")
upload.send_keys("F:\\aa.png")
time.sleep(5)
#提交編輯內容
driver.find_element_by_css_selector("#tab2_submit_form > div > button.btn_common.j-btnSubmit").click()
#關閉確認提交成功按鈕
driver.find_element_by_xpath("//*[@id=‘alert_hint_modal‘]/div[2]/div[3]/span").click()
time.sleep(5)
driver.find_element_by_css_selector("#tab2_submit_form > div > button.btn_common.j-btnBack").click()

企業庫(編輯2)