0

<div class="col-xs-3" xpath="1">
        <label>Service Duration in mins</label>
        <span class="k-widget k-numerictextbox k-overwrite" style="">
        <span class="k-numeric-wrap k-state-default">
        <input type="text" class="k-formatted-value k-overwrite k-input" title="500" tabindex="0" role="spinbutton" aria-valuemin="0" aria-valuenow="500" aria-disabled="false" style="display: inline-block;">
        <input class="k-overwrite k-input" data-val="true" data-val-number="The field DurationInMins must be a number." data-val-required="The DurationInMins field is required." id="DurationInMins" min="0" name="DurationInMins" type="text" value="0" data-role="numerictextbox" role="spinbutton" aria-valuemin="0" style="display: none;" aria-valuenow="500" aria-disabled="false">
        <span class="k-select">
        <span unselectable="on" class="k-link k-link-increase" aria-label="Increase value" title="Increase value">
        <span unselectable="on" class="k-icon k-i-arrow-60-up">
        </span>
        </span>
        <span unselectable="on" class="k-link k-link-decrease" aria-label="Decrease value" title="Decrease value">
        <span unselectable="on" class="k-icon k-i-arrow-60-down">
        </span>
        </span>
        </span>
        </span>
        </span>
        <script>
 kendo.syncReady(function(){jQuery("#DurationInMins").kendoNumericTextBox({"format":"{0:n0}"});});
</script>
    </div>

I tried to input values in spin button (Textbox with increment and decrement arrows). Below code throws an error:

Expected condition failed:waiting for element to be clickable.

Can anyone help me with this error...

Thanks in advance...

WebElement ele5=driver.findElement(By.xpath("//input[@id='DurationInMins']"));
JavascriptExecutor executor1=(JavascriptExecutor)driver;
executor1.executeScript("arguments[0].click()",ele5);
WebDriverWait wait1=new WebDriverWait(driver,10);
wait1.until(ExpectedConditions.elementToBeClickable(ele5));
ele5.clear();
ele5.sendKeys("45");
//Thread.sleep(2000);
Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
Sang
  • 33
  • 1
  • 7
  • I couldn't see the DurationInMins id in the above mentioned HTML. Whether you are meaning the input tag which has id as "Capacity"? – Subburaj Jun 14 '18 at 03:36
  • At the point style=“display: none;”, the element could not be clickable, bcs is not displayed. Your question seems to unreasonable. – pburgr Jun 15 '18 at 06:12

3 Answers3

2

As per the HTML you have shared, the desired element i.e. the input field is having the attribute style="display: none;". So to send a character sequence to the input field you can use the following solution:

WebElement ele5 = driver.findElement(By.xpath("//input[@class='k-overwrite k-input' and @id='DurationInMins']"));
((JavascriptExecutor)driver).executeScript("arguments[0].removeAttribute('style')", ele5)
ele5.clear();
ele5.sendKeys("45");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

try this code :

        WebDriverWait wait = new WebDriverWait(driver, 20);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@id='DurationInMins' and @name='DurationInMins' and contains(@data-val-required,'The DurationInMins field is required')]/preceding-sibling::input")));
        WebElement ele5 = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='DurationInMins' and @name='DurationInMins' and contains(@data-val-required,'The DurationInMins field is required')]/preceding-sibling::input")));
        ele5.clear();  
        ele5.sendKeys("45"); 

If this is the input field :

<input class="k-overwrite k-input" data-val="true" data-val-number="The field Capacity must be a number." data-val-required="The Capacity field is required." id="Capacity" min="0" name="Capacity" type="text" value="0" data-role="numerictextbox" role="spinbutton" aria-valuemin="0" style="display: none;" aria-valuenow="0" aria-disabled="false">  

Then you have to use : locator as :

By.id("Capacity")  

or

By.name("Capacity") 

or

By.cssSelector("input[role='spinbutton']") 

Hope this will be helpful.

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • I tried with your code and its throwing error as below: – Sang Jun 14 '18 at 05:49
  • org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: By.id: DurationInMins (tried for 10 second(s) with 500 milliseconds interval) – Sang Jun 14 '18 at 05:49
  • I tried with your Xpath code but still getting error as below: – Sang Jun 14 '18 at 06:19
  • org.openqa.selenium.ElementNotVisibleException: element not visible – Sang Jun 14 '18 at 06:19
  • and i tried adding Javascript Executor stmt and still getting the same error. – Sang Jun 14 '18 at 06:20
  • Can you check whether it's in iframe or not ? or can you visualize the input field when you run your script. – cruisepandey Jun 14 '18 at 06:21
  • Tried with your new code. Again the same error "element not visible". While running the script the cursor moves on to the text box but not accepting the value "45". – Sang Jun 14 '18 at 06:53
  • and you have not told me about iframe ? is it present in DOM or not ? – cruisepandey Jun 14 '18 at 07:02
  • I am not sure about iframes...How to check it?? – Sang Jun 14 '18 at 23:06
0

When executed this HTML I got this in UI inputbox

i.e only input box and not Textbox with increment and decrement arrows: further when inspecting the text box or input box I am able to enter into the text box using:

WebElement inputField = driver.findElement(By.cssSelector("span.k-state-default input"));
inputField.sendKeys("45");

There are two input fields present in HTML code and when trying to inspect it is the first input tag that is editable and it can be filled with values.

This should work if I got the exact idea of the UI that you have mentioned in the question i.e Textbox with increment and decrement arrows (As I do not see any arrow buttons )

Because while running HTML, in console it is showing kendo not defined and no increment/decrement buttons are visible.

tk3
  • 990
  • 1
  • 13
  • 18
dangi13
  • 1,275
  • 1
  • 8
  • 11