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
元素不可见-Selenium-Java Webdriver_Java_Selenium_Webdriver - Fatal编程技术网

元素不可见-Selenium-Java Webdriver

元素不可见-Selenium-Java Webdriver,java,selenium,webdriver,Java,Selenium,Webdriver,我试图在网站上填写表单,但找不到代码中列出的元素 我的代码: new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div[1]/form/div/div/input[1]"))); driver.findElement(By.xpath("/html/body/div[1]/form/div/div/input[1]")).se

我试图在网站上填写表单,但找不到代码中列出的元素

我的代码:

new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div[1]/form/div/div/input[1]")));
        driver.findElement(By.xpath("/html/body/div[1]/form/div/div/input[1]")).sendKeys("TEST");
相关网站代码:

<body>
   <div id="pf_form" class="pf_formcontainer">
   <form id="PF_1" class="form formBoxShadow" style="height: 1600px; width: 
      1800px; display: block; left: 0px; top: 30px;">
   <div id="PF_4Container" class="PageContainer" style="left:0px;top:0px;z-
      index:0;position:absolute">
   <div id="PF_4" class="page" tabindex="" name="PF_4" style="width: 1800px; 
      height: 1600px; background-color: rgb(255, 255, 255); display: block;">
   <input id="PF_5" class="textinput" name="PF_5" maxlength="99" value="" 
      onclick="return false;" style="left: 169px; top: 107px; z-index: 6; height: 
      18px; line-height: 18px; width: 206px; display: block;" type="text">
   ...

...
我试着换成了PF_4和PF_4的框架,但运气不好。我试着通过身份证和其他方式找到它,但这一个是踢我的屁股

该表单在此处公开可见


任何指导都将不胜感激。我已经尝试解决这个问题好几个星期了。

如果您已经有了带有ID的HTMl元素,为什么要使用xpath? 只需使用:

WebDriverWait wait = (new WebDriverWait(driver, 30));
WebElement input = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("PF_5")));
input.sendKeys("tests tests");

使用id时会出现什么错误?driver.findElement(By.id('PF_5'))。我没有看到任何iFrame…请使用控制台->谢谢Andrew中的求值路径尝试xpath路径是否正确。它似乎找不到元素。请随意在url上运行它。谢谢Christian!我添加了这个,但是返回的错误是:线程“main”org.openqa.selenium.ElementNotVisibleException中的异常:元素不可见