您好,登錄后才能下訂單哦!
這篇文章主要介紹“如何通過(guò)selenium查詢禪道是否有任務(wù)或者BUG”,在日常操作中,相信很多人在如何通過(guò)selenium查詢禪道是否有任務(wù)或者BUG問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”如何通過(guò)selenium查詢禪道是否有任務(wù)或者BUG”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
Python selenium 實(shí)例之通過(guò) selenium 查詢禪道是否有任務(wù)或者 BUG
1、封裝一下 selenium 的 driver
from selenium import webdriver driver = webdriver.Chrome() driver.set_window_size(1920, 1350) driver.set_page_load_timeout(7000) driver.set_script_timeout(7000) driver.set_window_position(300, 50)
2、封裝一下 selenium 的一些常用的獲取元素的方法
def fe_id(driver, id, send_keys): e = driver.find_element_by_id(id) e.send_keys(send_keys) def fe_name(driver, name, send_keys): e = driver.find_element_by_name(name) e.send_keys(send_keys) def fe_xpath(driver, xpath, send_keys): e = driver.find_element_by_xpath(xpath) e.send_keys(send_keys) def fe_id_click(driver, id): e = driver.find_element_by_id(id) e.click() def fe_name_click(driver, name): e = driver.find_element_by_name(name) e.click() def fe_xpath_click(driver, xpath): e = driver.find_element_by_xpath(xpath) e.click() def fe_id_clear(driver, id): e = driver.find_element_by_id(id) e.clear() def fe_name_clear(driver, name): e = driver.find_element_by_name(name) e.clear() def fe_xpath_clear(driver, xpath): e = driver.find_element_by_xpath(xpath) e.clear() def get_text_xpath(driver, xpath): e = driver.find_element_by_xpath(xpath) return e.text def get_text_id(driver, id): e = driver.find_element_by_id(id) return e.text def get_text_name(driver, name): e = driver.find_element_by_name(name) return e.text
3、代碼實(shí)例
from auto_selenium import config_selenium from auto_selenium.fast_set import * from time import sleep driver = config_selenium.driver # 看看禪道是否有任務(wù) def chandao(): driver.get('你的禪道地址') fe_xpath(driver, '//*[@id="account"]', '你的禪道帳號(hào)') fe_xpath(driver, '//*[@id="loginPanel"]/div/div[2]/form/table/tbody/tr[2]/td/input', '你的禪道密碼') fe_xpath_click(driver, '//*[@id="submit"]') sleep(1) task = get_text_xpath(driver, '//*[@id="block102"]/div[2]/div/div[2]/div/div[1]/div[2]') bug = get_text_xpath(driver, '//*[@id="block102"]/div[2]/div/div[2]/div/div[2]/div[2]') need = get_text_xpath(driver, '//*[@id="block102"]/div[2]/div/div[2]/div/div[3]/div[2]') if int(task) > 0: print('有任務(wù)') return if int(bug) > 0: print('有BUG') return if int(need) > 0: print('有需求') return print('暫無(wú)任何內(nèi)容') if __name__ == '__main__': chandao() driver.close()
4、運(yùn)行
如圖
到此,關(guān)于“如何通過(guò)selenium查詢禪道是否有任務(wù)或者BUG”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。