Bharati Belgaonkar
Bharati Belgaonkar

Reputation: 13

We have @FindBys and @FindAll in Selenium Java, how to use same code to find locators in Python

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.

Upvotes: 1

Views: 243

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193308

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
    

References

You can find a couple of relevant detailed discussions in:

Upvotes: 0

Related Questions