Selenium RC getTitle 方法
已经过去很长一段时间了:-)
我仍在学习 Selenium RC,并且使用 www.irishtimes.com 作为我的测试应用程序。
我有一个非常小的测试用例,由以下步骤组成:
Selenium selenium;
public void setUp() throws Exception {
super.setUp();
selenium = new DefaultSelenium("localhost",
SELENIUM_PORT,
"*firefox",
"http://www.irishtimes.com/");
setUp("http://www.irishtimes.com/", "*firefox");
}
public void testTCNewspapers() throws Exception {
selenium.start();
selenium.open("http://www.irishtimes.com/");
selenium.waitForPageToLoad("30000");
selenium.click("link=Life");
//Doesn't work
//verifyEquals("The Irish Times - Life", sel.getTitle());
在
执行 verifyEquals 时,我收到此错误:
java.lang.AssertionError: java.lang.AssertionError: Expected "The Irish Times - Life" but saw "The Irish Times – Irish News, Business News, Sports News & Ireland Weather Online" instead
com.thoughtworks.selenium.SeleneseTestBase.fail(SeleneseTestBase.java:356)
我不明白为什么会发生这种情况,因为页面的标题是“爱尔兰时报 - Life”
来自源 html 文件:
<title>The Irish Times - Life</title>
对解决这个问题有什么帮助吗?谢谢 ;-)
it's been a long time :-)
I'm still with my learning of Selenium RC and I'm using the www.irishtimes.com as my tested application.
I have a very tiny test case that consists of these steps:
Selenium selenium;
public void setUp() throws Exception {
super.setUp();
selenium = new DefaultSelenium("localhost",
SELENIUM_PORT,
"*firefox",
"http://www.irishtimes.com/");
setUp("http://www.irishtimes.com/", "*firefox");
}
public void testTCNewspapers() throws Exception {
selenium.start();
selenium.open("http://www.irishtimes.com/");
selenium.waitForPageToLoad("30000");
selenium.click("link=Life");
//Doesn't work
//verifyEquals("The Irish Times - Life", sel.getTitle());
}
When executing the verifyEquals I'm getting this error:
java.lang.AssertionError: java.lang.AssertionError: Expected "The Irish Times - Life" but saw "The Irish Times – Irish News, Business News, Sports News & Ireland Weather Online" instead
at com.thoughtworks.selenium.SeleneseTestBase.fail(SeleneseTestBase.java:356)
I don't understand why this is happening since the title of the page is "The Irish Times - Life"
From the source html file:
<title>The Irish Times - Life</title>
Any help on resolving this? Thanks ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Selenium 在发送“点击”后不会等待新页面加载。
尝试使用“clickAndWait” - 这应该会导致 Selenium 在继续之前等待服务器的响应。
Selenium doesn't wait for the new page to load after sending 'click'.
Try using 'clickAndWait' - that should cause Selenium to wait for a response from the server before continuing.
您需要告诉 Selenium 等待页面加载。
请参阅此处: Selenium IDE:输入太“早”
You need to tell Selenium to wait for the page to load.
See here: Selenium IDE : Input too "early"
我可以从源 html 文件中清楚地看到标题,
爱尔兰时报 – 爱尔兰新闻、商业新闻、体育新闻和爱尔兰天气在线我用chrome查看源码
I can clearly see the title from the source html file as,
The Irish Times – Irish News, Business News, Sports News & Ireland Weather Online I used chrome to view the source