0

I'm trying to click on the radio button that comes from in MODAL but a timeout exception comes every time.

Here is the DOM element with a modal screenshot

Here is the DOM element with a modal screenshot

I'm using the PAGE OBJECT MODEL design pattern and below is the code. I'm trying to click through the main input locator and also select the main class.

Explitroy wait:

def get_element_clickable(self, by_locator):
    WebDriverWait(self.driver, 30).until(EC.element_to_be_clickable(by_locator))

Call the locator in function:

    def get_select_radio(self):
        return self.get_element_clickable(self.Select_radio_button_of_modal)

Also, try this:

def get_element_clickable(self, by_locator):
        WebDriverWait(self.driver, 30).until(EC.visibility_of_element_located(by_locator))

Can someone please help suggest to me how to resolve this issue?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

To click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.addRemoveEFAW#haveEfaw"))).click()
    
  • Using XPATH:

    WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='addRemoveEFAW' and @id='haveEfaw']"))).click()
    
  • 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
    

PS: As you are using PAGE OBJECT MODEL the the within the respective PageObject.py page you have to define them accordingly.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352