Most likely you just need to wait for element to appear. Use explicit wait instead of findElement
:
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement txtAccountName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='txtAccountName']")));
txtAccountName.sendKeys("CRSsolutions_test_" + today + "_tanksafe");
This pattern allows to wait for up to 10 seconds, but will return faster if condition is satisfied. Condition elementToBeClickable
makes sure the field is clickable, which is a prerequisite for value to be inputed.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…