1

I would like to automate a test in Microsoft Redeem Code page

https://account.microsoft.com/billing/redeem

I tried to enter value by below code:

driver.findElement(By.id("tokenString")).sendKeys("GXXFV-CPMKR-VQVFV-2CCFD-J47GZ");

Inspect element showing:

<input aria-label="Enter 25-character code" name="tokenString" type="text" autocomplete="off" spellcheck="true" placeholder="Enter 25-character code" maxlength="tokenLength" autofocus="" autocorrect="off" autocapitalize="off" id="tokenString" class="ember-text-field ember-view">

I tried lot of ways nothing worked out , Spent 4 hrs cant figure out please correct my code Environment:

  • Eclipse IDE - Java - Selenium latest

  • Mac OS - Chrome

Correct Code to find element.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Dilz
  • 11
  • 1

1 Answers1

0

The desired element is a Ember.js enabled element, so to click() on the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategies:

  • cssSelector:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.ember-text-field.ember-view#tokenString[name='tokenString']"))).sendKeys("GXXFV-CPMKR-VQVFV-2CCFD-J47GZ");
    
  • xpath:

    new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='ember-text-field ember-view' and @id='tokenString'][@name='tokenString']"))).sendKeys("GXXFV-CPMKR-VQVFV-2CCFD-J47GZ");
    

Update

Checkout the following line of code:

  • cssSelector:

    new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input.ember-text-field.ember-view#tokenString[name='tokenString']"))).sendKeys("GXXFV-CPMKR-VQVFV-2CCFD-J47GZ");
    
  • xpath:

    new WebDriverWait(driver, Duration.ofSeconds(20)).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@class='ember-text-field ember-view' and @id='tokenString'][@name='tokenString']"))).sendKeys("GXXFV-CPMKR-VQVFV-2CCFD-J47GZ");
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • i'm using Selenium latest one , The constructor WebDriverWait(WebDriver, long) is deprecated. – Dilz Mar 27 '22 at 02:22
  • @Dilz Checkout the updated answer and let me know the status. – undetected Selenium Mar 27 '22 at 09:15
  • @undetectec Selenium. Not working Command: [f303bd41063d05b6c69168abb1252859, findElement {using=xpath, value=//input[@class='ember-text-field ember-view' and @id='tokenString'][@name='tokenString']}] – Dilz Mar 27 '22 at 18:42