-
Notifications
You must be signed in to change notification settings - Fork 0
/
element.py
51 lines (32 loc) · 1.3 KB
/
element.py
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
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.by import By
import time
import sys
reload(sys)
sys.setdefaultencoding('utf8')
def exists_by_xpath(driver, xpath):
try:
driver.find_element_by_xpath(xpath)
except NoSuchElementException:
return False
return True
def xpath(driver, path, wait=0, error='no'):
def xpaths(driver, path, wait=0, error='no'):
def classname(driver, path, wait=0, error='no'):
def classnames(driver, path, wait=0, error='no'):
def id(driver, path, wait=0, error='no'):
def ids(driver, path, wait=0, error='no'):
def name(driver, path, wait=0, error='no'):
def names(driver, path, wait=0, error='no'):
def linktext(driver, path, wait=0, error='no'):
def linktexts(driver, path, wait=0, error='no'):
def partiallinktext(driver, path, wait=0, error='no'):
def partiallinktexts(driver, path, wait=0, error='no'):
def tagname(driver, path, wait=0, error='no'):
def tagnames(driver, path, wait=0, error='no'):
def cssselector(driver, path, wait=0, error='no'):
def cssselectors(driver, path, wait=0, error='no'):