代码之家  ›  专栏  ›  技术社区  ›  Waqas Waheed

为什么文本保留在输入字段中,即使我使用selenium WebDriver java清除该字段并发送新密钥

  •  0
  • Waqas Waheed  · 技术社区  · 1 年前

    [这是我的HTML和web应用程序]( https://i.stack.imgur.com/nHfgC.png ) 这是我的代码:

    @Test(priority = 9)
        public void EditCompositeLevel() throws InterruptedException  {
    
            // Wait for the 'Name' input field to be present and clear its content
         WebElement nameInput=driver.findElement(By.xpath("//input[@type='text' and @placeholder='Name']"));
    
            Thread.sleep(3000);
            nameInput.clear();
          
            Thread.sleep(3000);
         System.out.println( driver.findElement(By.xpath("(//input[@placeholder='Name'])[1]")).getText()
           ) ; 
         
            Thread.sleep(3000);
            System.out.println( driver.findElement(By.xpath("(//input[@placeholder='Name'])[1]")).getText());
        }
    

    我尝试使用webobject-object.clear()来清除输入字段; 然后我想使用webobject对象sendkeys发送输入值。但它在我发送键之前保留了以前的输入值

    0 回复  |  直到 1 年前
    推荐文章