Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium代码不适用于Internet Explorer_Java_Eclipse_Internet Explorer_Firefox_Selenium - Fatal编程技术网

Java Selenium代码不适用于Internet Explorer

Java Selenium代码不适用于Internet Explorer,java,eclipse,internet-explorer,firefox,selenium,Java,Eclipse,Internet Explorer,Firefox,Selenium,我试图在EclipseIDE中使用Selenium和Java执行自动化测试 我的自动化测试源代码如下所示: TestClass.java package testproject; import login.*; public class TestClass { public static void main(String[] args) { SearchTest st = new LoginTest(); try { st.s

我试图在EclipseIDE中使用Selenium和Java执行自动化测试

我的自动化测试源代码如下所示:

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();
        }
    }

}
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"));            
    }
}
SearchTest.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();
        }
    }

}
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)并未打开。而不是指导我去
http://www.google.com
,RC服务器指示我进入
C:\Users\rugged.mandrekar\AppData\Local\Temp\customProfileDir1b3a3fa718214e7cae8240f4cf54293e\core\Blank.html
,如以下屏幕截图所示:

我在一天前创建了上述代码,它的执行非常完美。目前,该测试也在其他浏览器(如Chrome和Firefox)中进行。换句话说,当我将SearchTest.java文件第10行中的*iexplore更改为firefox或chrome时,就会执行测试。Selenium控制台日志中也有一条错误消息,从今天开始弹出。错误消息的屏幕截图如下所示:


谁能告诉我到底哪里出了问题?如能尽早答复,我们将不胜感激。提前感谢您。

在Internet Explorer:

  • 单击“站点”按钮并添加您正在使用的应用程序的URL 在
    中将此网站添加到区域中进行测试:
    并单击
    添加
    按钮

  • 禁用弹出块。-选择工具/弹出窗口阻止程序/关闭弹出窗口 拦截器

  • 禁用IE保护模式。-取消勾选工具/互联网选项/安全/启用保护模式

  • 确保以管理员身份运行Internet Explorer和IDE

代码中的

  • 尝试将浏览器字符串更改为
ISelenium selenium=new DefaultSelenium(“localhost”,4444,“*iexploreproxy,”http://www.google.com/");


您是否启用了弹出窗口阻止程序?非常感谢您的回复。不,我没有启用弹出窗口拦截器。很酷,可能是非常愚蠢的问题,但最好先做基本的事情!IE很烦琐,你是以管理员的身份运行它吗?我现在会看看代码等等,但最好先试试环境方面的东西。在IE中也可以尝试:点击“站点”按钮,在“将此网站添加到区域”中添加您正在测试的应用程序的URL,然后点击“添加”按钮。很抱歉重复评论,请尝试此
Internet选项>安全性>取消选中启用保护模式复选框,然后尝试运行脚本。
还可以以管理员身份运行所有内容,这意味着您的IDE和浏览器。好的,这就成功了。非常感谢你的帮助;非常感谢。干杯。:-)你回答的第二部分帮助我解决了这个问题,因为我已经关闭了弹出窗口拦截器。谢谢。:-)我的荣幸:)很高兴这有帮助。几周后我将在一份新工作中使用Selenium,我可能会有大约一百万个问题!