硒的基本问题。在
我正在尝试迭代站点中的一个类(没有id,没有名称),但是类名非常长,比如class="my really long crappy class name with space"
我正在尝试mydriver.find_elements_by_class_name(idClass);
,其中mydriver = webdriver.Firefox()
。在
我也尝试了my.really.long.crappy.class.name.with.space
,但这也不起作用(把它看作是对其他问题的解答,比如我)。当我运行这个,我没有得到一个错误,但我的结果是大小为零。在
下面的函数是我当前使用的,我正在打印
def getElementByClass(idClass):
a=[];
try:
print idClass;
a = mydriver.find_elements_by_class_name(idClass);
return a;
except:
print 'crap';
您可以使用^{} :
其中
class1
、class2
和class3
是元素的类名。在或者,另一个选择是使用^{} :
^{pr2}$如果事先知道标记名,也可以将
*
替换为它。在希望有帮助。在
相关问题 更多 >
编程相关推荐