Python Forum
wait.until(EC.element_to_be_clickable) failed to click
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wait.until(EC.element_to_be_clickable) failed to click
#1
def FindElementById(Element):
    clickable = wait.until(EC.element_to_be_clickable((By.ID, Element)))
    clickable.click()
Chrome.FindElementById("user-id")
It is not able to perform the click function, and it seems like waiting for the element to present.
Thus, I wait until got TimeOutException.
Then I try this method
time.sleep(3)
Chrome.FindElementById("user-id")
And it able to perform the click after 3 seconds wait.

May I know why?
Reply
#2
(Feb-21-2019, 04:11 PM)gahhon Wrote: def FindElementById(Element):
clickable = wait.until(EC.element_to_be_clickable((By.ID, Element)))
What exactly is your wait defined as? It should be WebDriverWait(driver, 3) but i cant see it.

Found this looking around
Quote:EC.element_to_be_clickable check if element is visible and enabled. In terms of visibility it doesn't cover scenario when element is behind other. Maybe your page use something like blockUI widget and click() occurs before the cover disappears. You can check if element is truly clickable by enriching EC.element_to_be_clickable((By.XPATH, x)) check with assertion that ensure element is not behind by other.

static bool IsElementClickable(this RemoteWebDriver driver, IWebElement element)
{
    return (bool)driver.ExecuteScript(@"
            (function(element){
                var rec = element.getBoundingClientRect();
                var elementAtPosition = document.elementFromPoint(rec.left+rec.width/2, rec.top+rec.height/2);
                return element == elementAtPosition || element.contains(elementAtPosition);
            })(arguments[0]);
    ", element);
}
Recommended Tutorials:
Reply
#3
(Feb-21-2019, 05:35 PM)metulburr Wrote:
(Feb-21-2019, 04:11 PM)gahhon Wrote: def FindElementById(Element):
clickable = wait.until(EC.element_to_be_clickable((By.ID, Element)))
What exactly is your wait defined as? It should be WebDriverWait(driver, 3) but i cant see it.

Found this looking around
Quote:EC.element_to_be_clickable check if element is visible and enabled. In terms of visibility it doesn't cover scenario when element is behind other. Maybe your page use something like blockUI widget and click() occurs before the cover disappears. You can check if element is truly clickable by enriching EC.element_to_be_clickable((By.XPATH, x)) check with assertion that ensure element is not behind by other.

static bool IsElementClickable(this RemoteWebDriver driver, IWebElement element)
{
    return (bool)driver.ExecuteScript(@"
            (function(element){
                var rec = element.getBoundingClientRect();
                var elementAtPosition = document.elementFromPoint(rec.left+rec.width/2, rec.top+rec.height/2);
                return element == elementAtPosition || element.contains(elementAtPosition);
            })(arguments[0]);
    ", element);
}


wait = WebDriverWait(instance, 30)
I just now try again it work again? @@
So sometime it work, sometime it not?
Reply
#4
did you raise the number to 30? IF so then you just need more time before timeout.
https://selenium-python.readthedocs.io/a...pport.wait

Another option is the site you are crawling flagged your IP address, and reset today.
Recommended Tutorials:
Reply
#5
(Feb-22-2019, 05:47 PM)metulburr Wrote: did you raise the number to 30? IF so then you just need more time before timeout.
https://selenium-python.readthedocs.io/a...pport.wait

Another option is the site you are crawling flagged your IP address, and reset today.

Yes. The application is executing until timeout till can't allocate the element.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need Help with Selenium Explicit Wait gw1500se 6 2,854 Nov-28-2021, 09:44 PM
Last Post: Larz60+
  selenium wait for text question Larz60+ 3 2,501 Oct-25-2021, 09:50 AM
Last Post: Larz60+
  drive wait in try windows11 0 1,802 Apr-07-2020, 01:50 PM
Last Post: windows11
  wait for element and click windows11 2 2,604 Mar-21-2020, 09:23 PM
Last Post: windows11

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020