1
driver.find_element_by_id("ch4_loginGuestBtn").click()

This command intermittently fails with:

"Element is not clickable"

I'm guessing I need to do something like the following.

    guestlogin_button = wait.until(EC.visibility_of_element_located((By.id, ".ch4_loginGuestBtn")))
    actions = ActionChains(driver)
    actions.move_to_element(guestlogin_button).click().perform()

This is however failing with:

AttributeError: type object 'By' has no attribute 'id'

What am I doing wrong, how do I fix the wait.until line?

david
  • 6,303
  • 16
  • 54
  • 91

3 Answers3

0

You probably need to change

guestlogin_button = wait.until(EC.visibility_of_element_located((By.id, ".ch4_loginGuestBtn")))

to

guestlogin_button = wait.until(EC.visibility_of_element_located((By.ID, ".ch4_loginGuestBtn")))
Naman
  • 27,789
  • 26
  • 218
  • 353
0
int count=0;
while (count < 4) {
    try {
        Webdriverwait wait = new Webdriverwait(driver,10);
        WebElement p = wait.until(ExpectedConditions.elementToBeClickable(By.xapth("")));
        driver.findelement(by.xapth("")).click
     } 
     catch (Exception e) 
     {
         System.out.println("Trying to recover from a exception :-");
         count = count + 1;
         continue;
     } 

     count = count + 4;
}
Phd. Burak Öztürk
  • 1,727
  • 19
  • 29
0

bad code but works:

i=0
while i<1:
   try:
      driver.find_element_by_id("ch4_loginGuestBtn").click()
      i==1
   except:

time.sleep(1) i==0

Carlo 1585
  • 1,455
  • 1
  • 22
  • 40