class = "col-scope serialize"
I have an element in HTML with class name like above. When I try to get the class name with getAttribute("class")
I am only getting the value col-scope
.
How can I get the complete value col-scope serialize
?
CodePudding user response:
At first, you have to select that class/classes then invoke .get_attribute("class")
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, '//*[@]'))).get_attribute("class")
CodePudding user response:
As @JaSON
mentioned in their comments:
Waiting for element with exact @class to extract that exact @class doesn't really make much sense
Solution
Ideally, to extract the value of the class
attribute you need to use the other attributes (other than class attribute) to locate the element first and then you can use getAttribute("class")
and you can use either of the following locator strategies:
Using cssSelector:
System.out.println(driver.findElement(By.cssSelector("tagName[attributeName='attributeValue']")).getAttribute("class"));
Using xpath:
System.out.println(driver.findElement(By.xpath("//tagName[@attributeName='attributeValue']")).getAttribute("class"));