Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Python Selenium中获取WebElement的类名?_Python_Selenium_Selenium Webdriver - Fatal编程技术网

如何在Python Selenium中获取WebElement的类名?

如何在Python Selenium中获取WebElement的类名?,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我使用SeleniumWebDriver从一个用JavaScript编写的网页中获取一个表 我正在迭代表行列表。每一行可能属于不同的类别。我想得到这个类的名称,这样我就可以为每一行选择合适的操作 table_body = table.find_element_by_tag_name('tbody') rows = table_body.find_elements_by_tag_name('tr') for row in rows: if (row.GetClassName()==&quo

我使用SeleniumWebDriver从一个用JavaScript编写的网页中获取一个表

我正在迭代表行列表。每一行可能属于不同的类别。我想得到这个类的名称,这样我就可以为每一行选择合适的操作

table_body = table.find_element_by_tag_name('tbody')
rows = table_body.find_elements_by_tag_name('tr')
for row in rows:
    if (row.GetClassName()=="date"):
        Action1()
    else:
        Action2()
硒有可能吗?或者建议另一种方法。

是您想要的:

row.get_attribute("class")