【发布时间】:2014-03-12 08:42:40
【问题描述】:
我是 Selenium 的新手。这是我的第一次尝试。我想通过 Selenium RC 访问新窗口中的元素。我有一个带有超链接的页面,单击它将打开新页面。我想在新窗口中输入用户名和密码元素。 html代码是
员工登录
新的页面元素是用于登录的“emailAddress”和“password”。
我的硒代码是
public static void main(String args[]) throws Exception
{
RemoteControlConfiguration rc=new RemoteControlConfiguration();
rc.setPort(2343);
SeleniumServer se= new SeleniumServer(rc);
Selenium sel=new DefaultSelenium("localhost",2343,"*firefox","http://neo.local/");
se.start();
sel.start();
sel.open("/");
sel.windowMaximize();
//sel.wait(1000);
sel.click("empLogin");
//sel.wait(2000);
//sel.openWindow("http://myneo.neo.local/user/login", "NewNeo");
//sel.waitForPopUp("NewNeo", "1000");
//sel.selectWindow("id=NewNeo");
Thread.sleep(20000);
sel.type("emailAddress", "kiranxxxxx@xxxxxx.com");
sel.type("password", "xxxxxxxx");
}
首先我尝试了正常的方法,但无法识别元素。然后我尝试使用 open window 和 selectWindow 选项,它通过像
这样的错误"Exception in thread "main" com.thoughtworks.selenium.SeleniumException: ERROR: Window locator not recognized: id
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:109)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:103)
at com.thoughtworks.selenium.DefaultSelenium.selectWindow(DefaultSelenium.java:377)
at Demo.main(Demo.java:24)"
有人告诉我,使用 Selenium RC 是不可能的。它只能通过 Selenium Webdriver 来实现。这是真的吗?
请帮忙, 提前致谢。
【问题讨论】:
-
谢谢 Nilesh 和 sircapsalot。我有一个 ID 为“empLogin”的锚标记。 http://myneo.neo.local/user/login" >员工登录。我用谷歌搜索了具体问题,发现只有 WebDriver 才有可能。无论如何感谢您的回答。
标签: selenium automation selenium-rc