Search code examples
javaselenium-webdriverextjsdatefield

Unable to identify extjs date field with partial ID


I’m working on an application in ExtJS, which is very dynamic in nature. I’m using selenium Webdriver, I could able to locate text fields, combo boxes in the page using the Partial ID (Contains, Startwith etc…), but unable to locate the Date field in the same page (Note: Only one date field exist in the page.). Please help me to identify this date field object.

I could able to access the combo box using the below code:

WebElement comb = driver.findElement(By.xpath(“//input[contains(@id, ‘combo’)]”));

Tried with the below and unable to locate the datefield:

WebElement dateBox = driver.findElement(By.xpath(“//input[contains(@id, ‘datefield’)]”));

HTML Details:

<input id=”datefield-1217-inputEl” data-ref=”inputEl” type=”text” role=”textbox” size=”1″ name=”dateOfBirth” maxlength=”10″ class=”x-form-field x-form-required-field x-form-text x-form-text-default x-form-invalid-field x-form-invalid-field-default” autocomplete=”off” componentid=”datefield-1217″>


Solution

  • I got a solution. Added Javascript in the code

    JavascriptExecutor jsexc3 = (JavascriptExecutor) driver;
    
    jsexc3.executeScript("Ext.getCmp('Componentname').queryById('formname').down('#itemId').setValue('"10/10/1990"')");