#coding=utf-8 from selenium import webdriver import time from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select driver = webdriver.Firefox() driver.get('http://58.215.9.181/users/sign_in.html') #采购人登陆 A = driver.find_element_by_id A('user_login').send_keys('cgr') A('user_password').send_keys('000000',Keys.ENTER)#登陆成功 #点击后台管理 time.sleep(2) driver.find_element_by_xpath("//a[@class='bue']").click() driver.find_element_by_id('tree_4_span').click() driver.switch_to.frame('75') time.sleep(4) driver.find_element_by_link_text('新增').click() driver.find_element_by_id('plan_name').send_keys('ceshi') a = driver.find_element_by_xpath("//select[@id='plan_zb_way']") Select(a).select_by_value('auction') b = driver.find_element_by_xpath("//select[@id='plan_fk_way']") Select(b).select_by_value('gkjzzf') c = driver.find_element_by_xpath("//select[@id='plan_wtjg']") Select(c).select_by_value('zxcg') e= driver.find_element_by_xpath("//select[@id='plan_cgxs']") Select(e).select_by_value('auction') f= driver.find_element_by_xpath("//select[@id='plan_zjly']") Select(f).select_by_value('czzj') #采购明细 driver.find_element_by_xpath("//*[@class='btn btn-small btn-primary add_nested_fields']").click() print'ok' driver.find_element_by_xpath(".//input[contains(@name,'][name]')]").send_keys(u'测试') driver.find_element_by_xpath(".//input[contains(@id,'xy_catalog_id_')]").click() time.sleep(1) driver.find_element_by_link_text('台式电脑').click() driver.find_element_by_xpath(".//input[contains(@name,'][unit]')]").send_keys(u'台')#计量单位 driver.find_element_by_xpath(".//input[contains(@name,'][num]')]").send_keys('11')#数量 driver.find_element_by_xpath(".//input[contains(@name,'][price]')]").send_keys(6500)#单价 driver.find_element_by_xpath(".//textarea[contains(@name,'][money_from]')]").send_keys(u'技术参数配置随便') driver.find_element_by_xpath(".//textarea[contains(@name,'][remark]')]").send_keys(u'商务要求') driver.find_element_by_xpath("//input[@class='button btn btn-primary btn-small mt10 w50']").click() time.sleep(1) driver.find_element_by_xpath("/html/body/div/table/tbody/tr[2]/td[8]/div/button").click() time.sleep(0.5) driver.find_element_by_xpath("/html/body/div/table/tbody/tr[2]/td[8]/div/ul/li[5]/a").click() time.sleep(1) driver.switch_to.alert.accept() driver.quit() #调用采购人审核模块 import os os.system("python C:\Users\Administrator\PycharmProjects\ceshi\cgksh.py")