Selenium Web驱动程序可自动执行Oracle ADF登录

时间:2020-06-26 04:02:43

标签: selenium

这是我在堆栈溢出中的第一篇文章,因此,如果我没有提供任何重要细节,请原谅我。

我目前正在尝试使用Selenium Web驱动程序编写Java代码来自动执行Oracle ADF登录,然后执行各种测试,但是失败并出现以下错误

目前,我有以下代码。这里不尝试做任何花哨的事情,而只是尝试发送用户名,但是失败了。我在这里做什么错了?

    public static void main (final String[] args) throws InterruptedException {


System.out.println("*******************");
System.out.println("Launching FF browser");
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
driver = new FirefoxDriver();

driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

driver.get("http://fusion11.com.au:19000/workspace/index.jsp");
String ActualTitle = driver.getTitle();
System.out.println(ActualTitle);
String ExpectedTitle = "Oracle Enterprise Performance Management System Workspace, Fusion Edition";
Assert.assertEquals(ExpectedTitle, ActualTitle);
    
Boolean verifyTitle = ActualTitle.equalsIgnoreCase("Oracle Enterprise Performance Management System Workspace, Fusion Edition");
System.out.println(verifyTitle);
WebElement GetUserName= driver.findElement(By.xpath("//*[@id=\"bpm.Logon.1.txtUser\"]"));
GetUserName.sendKeys("username");
System.out.println(GetUserName);

}

失败,并出现以下错误 Selenium - Unable to Locate Element

1 个答案:

答案 0 :(得分:0)

对于定位器// * [@@ =“ =” bpm.Logon.1.txtUser“]

在bpm之前删除\,然后在txtuser之后删除\

示例-

Thread.sleep(5000); //这是为了防止您的隐式等待不起作用

Blockquote

WebElement GetUserName = driver.findElement(By.xpath(“ // * [@ id =” bpm.Logon.1.txtUser“]”)))