<table >
<tbody>
<tr >
<td classs"sc-jEECVv IBUtl">
</td>
</tr>
When I use Selenium's Find element by class it is able to find the element, I even tried replacing space (after e and r or v and I) with ".", "-" and "_" but it did not worked. I Used The Code Below
try:
match_history_table = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.CLASS_NAME, 'sc-fAEnHe ePMtc'))
)
except Exception:
print("Error Finding Match History Table")
driver.quit()
It always returned the Exception (EC is selenium.webdriver.support.expected_conditions) >Note: Find Elements By Tag is not an Option For me
CodePudding user response:
This is doc from By.CLASS_NAME found in selenium-java-bindings.
Find elements based on the value of the "class" attribute. Only one class name should be used. If an element has multiple classes, please use cssSelector(String).
Try with (By.CSS_SELECTOR, '.sc-fAEnHe.ePMtc'):
try:
match_history_table = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.CSS_SELECTOR, '.sc-fAEnHe.ePMtc'))
)
except Exception:
print("Error Finding Match History Table")
driver.quit()
Referenses
- json wire protocol https://www.selenium.dev/documentation/legacy/json_wire_protocol/#sessionsessionidelement
class name Returns an element whose class name contains the search value; compound class names are not permitted.
W3C webdriver
And class_name not mentioned in W3C protocol, so it might become legacy https://www.w3.org/TR/webdriver/#locator-strategies
CodePudding user response:
- when you search for class name value, notice that "sc-fAEnHe ePMtc" represent 2 class names separated by space, so you can search by "sc-fAEnHe" or by "ePMtc"
- besides that make sure that presence_of_element_located doesn't require an element with height and width that greater then 0
