簡單 UI Testing Script

 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
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

#使用chrome的webdriver
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

driver = webdriver.Chrome(options=chrome_options)

# 開啟全螢幕
driver.maximize_window()

#開啟google首頁
driver.get('https://personal-vknq.outsystemscloud.com/Test/WebScreen3.aspx')


# Pagination
pagination = driver.find_element('xpath', '//*[@id="wt70_OutSystemsUIWeb_wt18_block_wtContent_wtMainContent_RichWidgets_wt31_block_wtPageNavigator_ctl02_wtLink8"]')

pagination.click()

time.sleep(5)

print('2nd page 已完成')


# Search Keyword
input_search = driver.find_element('xpath', '//*[@id="wt70_OutSystemsUIWeb_wt18_block_wtContent_wtMainContent_OutSystemsUIWeb_wt13_block_wtInput_wtSearchInput"]')
input_search.send_keys('some')

time.sleep(5)

print('Search已完成')

# Table Sort
columns = [1, 3, 4]

for col_num in columns:
    col = driver.find_element('xpath', '//*[@id="wt70_OutSystemsUIWeb_wt18_block_wtContent_wtMainContent_wtTable"]/thead/tr/th[{}]'.format(col_num))
    col.click()
    time.sleep(5)
    print('col{}正向已完成'.format(col_num))


# Table Sort
columns = [1, 3, 4]

for col_num in columns:
    col = driver.find_element('xpath', '//*[@id="wt70_OutSystemsUIWeb_wt18_block_wtContent_wtMainContent_wtTable"]/thead/tr/th[{}]'.format(col_num))
    col.click()
    time.sleep(5)
    print('col{}反向已完成'.format(col_num))
comments powered by Disqus