脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - Python selenium 实例之通过 selenium 查询禅道是否有任务或者BUG

Python selenium 实例之通过 selenium 查询禅道是否有任务或者BUG

2022-01-18 15:58简简单单OnlineZuozuo Python

这篇文章主要介绍了Python selenium 实例之通过 selenium 查询禅道是否有任务或者BUG的相关资料,本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下

Python selenium 实例之通过 selenium 查询禅道是否有任务或者 BUG

1、封装一下 selenium 的 driver

?
1
2
3
4
5
6
7
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 的一些常用的获取元素的方法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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、代码实例

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from auto_selenium import config_selenium
from auto_selenium.fast_set import *
from time import sleep
 
driver = config_selenium.driver
 
 
# 看看禅道是否有任务
def chandao():
    driver.get('你的禅道地址')
 
    fe_xpath(driver, '//*[@id="account"]', '你的禅道帐号')
    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('有任务')
        return
    if int(bug) > 0:
        print('有BUG')
        return
    if int(need) > 0:
        print('有需求')
        return
    print('暂无任何内容')
 
 
if __name__ == '__main__':
    chandao()
    driver.close()

4、运行

如图

Python selenium 实例之通过 selenium 查询禅道是否有任务或者BUG

到此这篇关于Python selenium 实例之通过 selenium 查询禅道是否有任务或者BUG的文章就介绍到这了,更多相关Python selenium 禅道BUG内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://wretchant.blog.csdn.net/article/details/120549965

延伸 · 阅读

精彩推荐