We have @FindBys and @FindAll in Selenium Java, how to use same code to find locators in Python?
@FindBys( { @FindBy(className = "class1") @FindBy(className = "class2")} )
Please guide me someone.
You have multiple ways:
Using lambda and CLASS_NAME:
WebDriverWait(driver,20).until(lambda driver: driver.find_element(By.CLASS_NAME, "class1") or driver.find_element(By.CLASS_NAME, "class2"))
Using CSS_SELECTOR:
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".class1, .class2"))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
You can find a couple of relevant detailed discussions in: