Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Text Selenium Webdriver正在发送密钥,但字段中未显示任何文本_Text_Selenium_Webdriver_Field_Sendkeys - Fatal编程技术网

Text Selenium Webdriver正在发送密钥,但字段中未显示任何文本

Text Selenium Webdriver正在发送密钥,但字段中未显示任何文本,text,selenium,webdriver,field,sendkeys,Text,Selenium,Webdriver,Field,Sendkeys,我正在使用SeleniumWebDriverChrome。我看到了一些很奇怪的事情。我正在测试一个注册帐户。Webdriver将进入每个字段,看起来像是在输入文本,但没有显示任何内容。字段中没有显示文本结果。我做错了什么 @Test public void testAlreadyUsedEmailSignUp() throws InterruptedException { driver.findElement(By.cssSelector("html body.oneColFixCtr

我正在使用SeleniumWebDriverChrome。我看到了一些很奇怪的事情。我正在测试一个注册帐户。Webdriver将进入每个字段,看起来像是在输入文本,但没有显示任何内容。字段中没有显示文本结果。我做错了什么

@Test
public void testAlreadyUsedEmailSignUp() throws InterruptedException {
     driver.findElement(By.cssSelector("html body.oneColFixCtrHdr div.container div#header div#innerHeader div#menu ul div.btn-gr")).click();
    Thread.sleep(5000);
    // switch to frames inside the webpage
    driver.switchTo().frame("GB_frame"); // 1st frame
    driver.switchTo().frame(0); // 2nd frame
    driver.findElement(By.id("firstName")).click();
    driver.findElement(By.id("firstName")).sendKeys("Tester");
    driver.findElement(By.id("lastName")).sendKeys("Automater");
    driver.findElement(By.id("email")).sendKeys("test11@gmail.com");
    driver.findElement(By.id("Ppassword")).sendKeys("prd1");
    driver.findElement(By.id("confirmPPassword")).sendKeys("pass7ord1");
    driver.findElement(By.id("State")).sendKeys("I");

    driver.findElement(By.id("myInput")).sendKeys("Mike Ward");

    Thread.sleep(2000);

    driver.findElement(By.name("term")).click();
    driver.findElement(By.id("formAccSubmit")).click();

    assertEquals(driver.findElement(By.id("errorContainer")).getText(),
            "The Email field must contain a valid email address.");

    Thread.sleep(5000);
}

使用下面的代码,您的问题将得到解决,删除或.getProperty并使用您的属性

String txtuserzipID = OR.getProperty("txt_UserZip_ID"); 
WebElement txtuserZipInput = driver.findElement(By.id(txtuserzipID));
txtuserZipInput.clear(); 
txtuserZipInput.sendKeys(String.valueOf(79081));
txtuserZipInput = driver.findElement(By.id(txtuserzipID));
new Actions(driver).sendKeys(driver.findElement(By.id(OR.getProperty("txt_UserZip_ID"))), 
"").perform();
希望它能起作用并解决您的问题。
谢谢

你怎么知道它的输入文本?它是否登录?您确定正在检索输入字段而不是覆盖在其上的某个div吗?有时web应用程序不会将键入的数据保存在字段中。我也面临同样的问题。之后,通过使用上述代码,我解决了我的问题。。