Python读取ini文件打印结果时提示AttributeError: 'str' object has no attribute 'find_element_by_xpath'
其他问答
1
读取ini文件后查看元素,打印结果时一直提示AttributeError: 'str' object has no attribute 'find element by_xpath',哪位大神帮忙看下哪里出了问题,感谢
coding=utf-8
from base.read_ini import *
class FindElement(object):
def __init__(self, driver):
self.driver = driver
def find_element(self, key):
read_ini = ReadIni()
data = read_ini.get_register_element(key)
by = data.split(">")[0]
values = data.split(">")[1]
# try:
if by == "id":
return self.driver.find_element_by_id(values)
elif by == "xpath":
return self.driver.find_element_by_xpath(values)
elif by == "classname":
return self.driver.find_element_by_class_name(values)
# except:
# return None
if name == "main":
ft = FindElement("driver")
fl = ft.find_element("username")
print(fl)
发表回复