When I click on a button, it displays me a form with other buttons, and I want to click on one of them. Here is a video with this (very brief), please see http://screencast.com/t/zyliSemW1s1
So I click the Buy Tickets button just like that:
button.Click();
And then I wait for the next button to be available.
I am using the following code:
WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(15)); IWebElement element = wait.Until(ExpectedConditions.ElementToBeClickable(myButton));
After that, I click the button that I was waiting for:
element.Click();
And I get the error: The item cannot be pressed at this point.
As I know, the ExpectedConditions.ElementToBeClickable () method expects 2 conditions: the element is visible and the element is enabled.
When I use Thread.Sleep (3000), before clicking on the second button, the code works and the button is available.
I saw a similar problem, and the solution was to wait for the handlers of this button: Selenium Wait does not wait for Element to be clicked
But what if I donβt know what can handle this? I think it handles jQuery, and I use the following code to wait until it stops executing:
var ajaxIsComplete = (bool) ((IJavaScriptExecutor)Driver).ExecuteScript("return jQuery.active == 0");
If it returns false, I wait and check again.
But that still doesn't work.
So now my thread is as follows:
- I click the Buy Tickets button
- I'm waiting for jQuery to stop executing
- I'm waiting for the item to be accessible using the ExpectedConditions.ElementToBeClickable () method
- I click on an element and it returns me an error that cannot be pressed.
Please guys tell me what is wrong in my flow and how to properly manage it.
Update : I am adding button HTML code:
I click on this:
<button class="btn btn-warning play-now" name="button" type="submit">Buy Tickets</button>
And wait for it:
<img alt="Credit Card" class="merchant" src="https://numgames-production.s3.amazonaws.com/uploads/merchant/image/21/CC_Offline.png?AWSAccessKeyId=AKIAJ2Q64HPERGHAJJUA&Expires=1470984765&Signature=Qj%2BFSQ3ElctkY6KTMfzp%2FedPjPo%3D">