<bdo id='dU8RG'></bdo><ul id='dU8RG'></ul>
    <i id='dU8RG'><tr id='dU8RG'><dt id='dU8RG'><q id='dU8RG'><span id='dU8RG'><b id='dU8RG'><form id='dU8RG'><ins id='dU8RG'></ins><ul id='dU8RG'></ul><sub id='dU8RG'></sub></form><legend id='dU8RG'></legend><bdo id='dU8RG'><pre id='dU8RG'><center id='dU8RG'></center></pre></bdo></b><th id='dU8RG'></th></span></q></dt></tr></i><div id='dU8RG'><tfoot id='dU8RG'></tfoot><dl id='dU8RG'><fieldset id='dU8RG'></fieldset></dl></div>

    <tfoot id='dU8RG'></tfoot>

      1. <small id='dU8RG'></small><noframes id='dU8RG'>

      2. <legend id='dU8RG'><style id='dU8RG'><dir id='dU8RG'><q id='dU8RG'></q></dir></style></legend>

        如何在文本框中定位和输入内容

        时间:2023-07-13
          <tbody id='uxKou'></tbody>
        <legend id='uxKou'><style id='uxKou'><dir id='uxKou'><q id='uxKou'></q></dir></style></legend>

          <small id='uxKou'></small><noframes id='uxKou'>

              <i id='uxKou'><tr id='uxKou'><dt id='uxKou'><q id='uxKou'><span id='uxKou'><b id='uxKou'><form id='uxKou'><ins id='uxKou'></ins><ul id='uxKou'></ul><sub id='uxKou'></sub></form><legend id='uxKou'></legend><bdo id='uxKou'><pre id='uxKou'><center id='uxKou'></center></pre></bdo></b><th id='uxKou'></th></span></q></dt></tr></i><div id='uxKou'><tfoot id='uxKou'></tfoot><dl id='uxKou'><fieldset id='uxKou'></fieldset></dl></div>
              <tfoot id='uxKou'></tfoot>

                <bdo id='uxKou'></bdo><ul id='uxKou'></ul>

                  本文介绍了如何在文本框中定位和输入内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  public class testFluent {   
                  
                  WebDriver driver;   
                      @Before
                          public void setUp(){        
                      driver = new FirefoxDriver();
                      driver.manage().window().maximize();
                      driver.manage().deleteAllCookies();}
                  
                           @Test
                          public void myFirstFluent(){
                          WebElement element;
                          driver.get("http://www.yahoo.com");         
                          element = myDynamicElement(By.id("//*[@id='p_13838465-p']"));
                          System.out.println("Element found");
                          }
                  
                          public WebElement myDynamicElement(final By locator){
                  
                          Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
                                      .withTimeout(10, TimeUnit.SECONDS)
                                      .pollingEvery(100, TimeUnit.MILLISECONDS)
                                      .ignoring(NoSuchElementException.class);
                  
                              WebElement element = wait.until(new Function<WebElement, WebDriver>(){
                  
                                  public WebElement apply(WebDriver drv){
                                      return drv.findElement(By.id(locator));
                                  }
                              });
                  
                                  return element;
                          }
                  
                      }
                  

                  我无法定位并以错误结尾.

                  I am unable to locate and ends with Error.

                  java.lang.Error: 未解决的编译问题:Wait 类型中的方法 until(Function) 不适用于参数 (new Function(){}) 函数无法解析为类型

                  java.lang.Error: Unresolved compilation problems: The method until(Function) in the type Wait is not applicable for the arguments (new Function(){}) Function cannot be resolved to a type

                  类型By中的方法id(String)不适用于com.junit.qa.testFluent.myDynamicElement(testFluent.java:49)处的参数(By)

                  The method id(String) in the type By is not applicable for the arguments (By) at com.junit.qa.testFluent.myDynamicElement(testFluent.java:49)

                  推荐答案

                  等一下你可以用这样的东西

                  For wait you can use something like this

                      private boolean wAit(String match)
                      {
                      try
                          {
                          (new WebDriverWait(driver, 30))
                              .until(ExpectedConditions.presenceOfElementLocated (By.xpath(match)));
                          return true;
                          }
                      catch (NoSuchElementException e) {
                          return false;
                      }
                      }
                  

                  您可以创建上述方法并在需要等待元素的任何地方使用它.例如

                  You can create the above method and use it where ever you need to wait for an element. for example

                  如果想在文本框中写一些东西并想等待文本框加载

                  if want a write something in the textbox and want to wait for the text box to load

                  wAit(" xpath of the textbox here")
                  driver.findelements... sendkeys()..
                  

                  如果您愿意,您可以更改定位器类型并增加/减少时间限制

                  If you want you can change the locator type and increase/decrease the time limit also

                  这篇关于如何在文本框中定位和输入内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在获取所有链接时,忽略循环中的注销链接并继续在 selenium java 中导航 下一篇:如何使用 Selenium WebDriver 和 Java 获得选定的选项

                  相关文章

                    <legend id='vcgCP'><style id='vcgCP'><dir id='vcgCP'><q id='vcgCP'></q></dir></style></legend>

                    1. <i id='vcgCP'><tr id='vcgCP'><dt id='vcgCP'><q id='vcgCP'><span id='vcgCP'><b id='vcgCP'><form id='vcgCP'><ins id='vcgCP'></ins><ul id='vcgCP'></ul><sub id='vcgCP'></sub></form><legend id='vcgCP'></legend><bdo id='vcgCP'><pre id='vcgCP'><center id='vcgCP'></center></pre></bdo></b><th id='vcgCP'></th></span></q></dt></tr></i><div id='vcgCP'><tfoot id='vcgCP'></tfoot><dl id='vcgCP'><fieldset id='vcgCP'></fieldset></dl></div>
                      • <bdo id='vcgCP'></bdo><ul id='vcgCP'></ul>

                      <small id='vcgCP'></small><noframes id='vcgCP'>

                      <tfoot id='vcgCP'></tfoot>