Can you use Selenium's EC.presence_of_element_located with a class selector instead of an ID selector?
You're trying to use Selenium's EC.presence_of_element_located method to wait for an element with the class ng-binding ng-scope to become present on a web page, but it's not working. The error message you're getting is:
Message: invalid selector: Compound class names not permitted
This error occurs because EC.presence_of_element_located does not support using multiple class names in its selector.
Solution
To wait for an element with a specific class using Selenium, you can use the By.CLASS_NAME locator. Here's how you can modify your code:
element = WebDriverWait(driver, 100).until(EC.presence_of_element_located((By.CLASS_NAME, "ng-binding ng-scope")))
This code will wait for an element with the class ng-binding ng-scope to become visible on the page.
Additional Notes
In some cases, you may also need to use the EC.visibility_of_element_located method instead of EC.presence_of_element_located. This method will wait for the element to become not only present but also visible on the page.
The above is the detailed content of Can Selenium's EC.presence_of_element_located Use Class Selectors Instead of IDs?. For more information, please follow other related articles on the PHP Chinese website!