当我尝试运行此代码时,我无法找到任何网络元素
package PremisesManagement;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
public class openbravo {
@Test
public void openbravoLoginTest() throws InterruptedException
{
System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver.exe");
WebDriver d = new ChromeDriver();
d.get("http://119.81.222.91:8080/camps/security/Login_FS.html");
Thread.sleep(3000);
d.findElement(By.id("user")).sendKeys("xyz");
WebDriverWait wait = new WebDriverWait(d, 120);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("//button[@id='buttonOK']")));
d.findElement(By.xpath("//button[@id='buttonOK']")).click();
}
}
答案 0 :(得分:0)
实际找到的元素位于ID为frame
的{{1}}内,因此您需要在找到元素之前切换此paramFrame1
,如下所示: -
frame