[英]Selenium Code Not Working for Internet Explorer
我正在尝试在Eclipse IDE中使用带有Java的Selenium进行自动化测试。
我的自动化测试源代码如下:
TestClass.java
package testproject;
import login.*;
public class TestClass {
public static void main(String[] args) {
SearchTest st = new LoginTest();
try {
st.setUp();
st.testNew();
} catch (Exception e) {
e.printStackTrace();
}
}
}
SearchTest.java
package login;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class SearchTest extends SeleneseTestBase {
public void setUp() throws Exception {
setUp("http://www.google.com/", "*iexplore");
}
public void testNew() throws Exception {
selenium.open("/");
selenium.type("q", "selenium rc");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("Results * for selenium rc"));
}
}
我有Windows 8系统,并且已经为Internet Explorer,Firefox和Chrome下载了正确的Selenium Web驱动程序。
这里的问题是,尽管设置了环境变量并通过执行jar文件从命令提示符启动Selenium RC服务器,但未打开网站(Google)。 RC服务器没有将我定向到http://www.google.com
,而是将我定向到C:\\Users\\rugved.mandrekar\\AppData\\Local\\Temp\\customProfileDir1b3a3fa718214e7cae8240f4cf54293e\\core\\Blank.html
如以下屏幕截图所示:
我一天前创建了上面的代码,并且执行得很好。 目前,该测试也在其他浏览器(例如Chrome和Firefox)中执行。 换句话说,当我将SearchTest.java文件中第10行中的* iexplore更改为firefox或chrome时,将执行测试。 Selenium控制台日志中也有一条错误消息,该消息从今天开始开始弹出。 错误消息的屏幕截图如下:
谁能告诉我我到底在哪里错? 最早的答复将不胜感激。 先感谢您。
在Internet Explorer中:
单击“站点”按钮,然后在“ Add this website to the zone:
中Add this website to the zone:
正在测试的应用程序的Add this website to the zone:
,然后单击“ Add
按钮。
禁用弹出框。 -选择Tools/Popup Blocker/Turn off pop-up blocker
禁用IE保护模式。 -取消Tools/Internet Options/Security/Enable protected mode
确保以管理员身份运行Internet Explorer和IDE。
在代码中
ISelenium selenium = new DefaultSelenium("localhost", 4444, "*iexploreproxy", "http://www.google.com/");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.