是否可以获取类属性的内容,以及如何实现?
答案 0 :(得分:0)
该类的名称为self。
tform = driver.find_elements_by_xpath("//table[@id = 'table-type-1']/tbody/tr/td[@class ='form col_form']/div/a[@class]")
Print(tform.text)返回正确的命中数,但字符串为空
答案 1 :(得分:0)
尝试一下。
linkClass = driver.find_element_by_xpath("//table[@id = 'table-type-1']/tbody/tr/td[@class ='form col_form']/div/a").get_attribute('class')
print(linkClass)
答案 2 :(得分:0)
linkClass = driver.find_elements_by_xpath("//table[@id = 'table-type-1']/tbody/tr/td[@class ='form col_form']/div/a[@href]").__getattribute__('class')
AttributeError:“列表”对象没有属性“类”