不要运行explorer_在Internet Explorer浏览器上运行测试

不要运行explorer

Running tests in IE is quite easy. Internet Explorer can’t be launched directly, we have to communicate with the Internet Explorer through Internet Explorer driver.

在IE中运行测试非常容易。 Internet Explorer无法直接启动,我们必须通过Internet Explorer驱动程序与Internet Explorer进行通信。

Internet Explorer驱动程序服务器 (Internet Explorer Driver Server)

Internet Explorer Driver Server is the link between your selenium tests and the Internet Explorer browser. As selenium WebDriver has no native implementation of IE, we have to address all the driver commands through IE driver server.

Internet Explorer驱动程序服务器是您的Selenium测试和Internet Explorer浏览器之间的链接。 由于Selenium WebDriver没有IE的本机实现,因此我们必须通过IE驱动程序服务器解决所有驱动程序命令。

下载并安装Internet Explorer驱动程序 (Download and Install Internet Explorer Driver)

IE driver server is an executable file that needs to have in one of the system paths before running your tests. The following are the steps to download Internet Explorer Driver.

IE驱动程序服务器是一个可执行文件,在运行测试之前,该文件需要包含在系统路径之一中。 以下是下载Internet Explorer驱动程序的步骤。

  • Step 1: Go to the Selenium official website and select appropriate version for Internet Explorer driver based on your operating system

    步骤1 :转到Selenium官方网站,然后根据您的操作系统为Internet Explorer驱动程序选择适当的版本。
  • Note: Here we are working on Windows Operating system, we need to download the corresponding IE driver of Windows version. If your Operating System is Linux or Mac then you need to download the latest release of Internet Explorer driver which is compatible with your test environment.

    注意:此处我们正在Windows操作系统上工作,我们需要下载Windows版本的相应IE驱动程序。 如果您的操作系统是Linux或Mac,则需要下载与您的测试环境兼容的Internet Explorer驱动程序的最新版本。

    IE Driver Server

    IE Driver Server

    IE驱动程序服务器

  • Step 2: Once the ZIP file download is complete, extract the ZIP file and keep it somewhere on a known location on your system.

    步骤2 :ZIP文件下载完成后,解压缩ZIP文件并将其保存在系统上的某个已知位置。
  • 使用IE时要记住的要点 (Points to remember when working with IE)

  • Zoom level should set to 100%

    缩放比例应设置为100%
  • Protected mode should be turned off and make a level to least positions ie to bottom down position.

    保护模式应关闭,并将水平调至最低位置,即向下至最低位置。
  • When we run Selenium WebDriver Script in Internet Explorer browser, we may fail to launch IE driver using Selenium WebDriver. Below are the two errors users may face when we run Selenium WebDriver Scripts in IE browser when we won’t set above two points.

    在Internet Explorer浏览器中运行Selenium WebDriver脚本时,我们可能无法使用Selenium WebDriver启动IE驱动程序。 以下是我们在IE浏览器中没有设置以上两点时运行Selenium WebDriver脚本时用户可能会遇到的两个错误。

    使用Selenium WebDriver无法启动IE驱动程序 (Failed to Launch IE Driver using Selenium WebDriver)

    Sometimes many of the Selenium WebDriver users failed to launch IE driver using Selenium WebDriver. To get rid of the common issues here are the solutions most of the users might have faced.

    有时,许多Selenium WebDriver用户无法使用Selenium WebDriver启动IE驱动程序。 要摆脱常见问题,这里是大多数用户可能面临的解决方案。

    错误1: (Error 1:)

    Exception in thread “main” org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. In IE browser Protected Mode settings are not the same for all zones. Protected Mode must be set to the same value for all zones.

    线程“主”中的异常org.openqa.selenium.remote.SessionNotFoundException:启动Internet Explorer发生意外错误。 在IE浏览器中,并非所有区域的保护模式设置都相同。 所有区域的保护模式必须设置为相同的值。

    Solution: To fix the error, we need to enable protected mode for all zones and mode should be turned off and make a level to least positions i.e to bottom down position.

    解决方案:要纠正该错误,我们需要为所有区域启用保护模式,并且应该关闭该模式,并将级别降至最低位置,即向下至最低位置。

    Below are the steps to enable protected mode for all zones.

    以下是为所有区域启用保护模式的步骤。

  • Step 1: Open Internet Explorer

    步骤1:打开Internet Explorer
  • Step 2: Go toTools menu – Internet Options

    步骤2:进入“ 工具”菜单-“ Internet选项”
  • Internet Options

    Internet Options

    互联网选项

  • Step 3: Select Security Tab

    步骤3:选择“ 安全性”选项卡
  • Security

    Security

    安全

  • Step 4: In Select a zone to view or change security settings choose Internet and select the check box of Enable protected mode (requires restarting Internet Explorer).

    步骤4:在“ 选择要查看或更改安全设置的区域”中,选择“ Internet”,然后选中“ 启用保护模式 ”复选框(需要重新启动Internet Explorer)。
  • Internet

    Internet

    互联网

  • Step 5: Similarly, select the check box of Enable protected mode (requires restarting Internet Explorer) for other three such as Local Intranet, Trusted sites, and Restricted sites.

    步骤5:同样,选中其他三个诸如本地Intranet,受信任的站点和受限制的站点启用保护模式 (需要重新启动Internet Explorer)复选框
  • Local Intranet

    Local Intranet

    本地内部网

    错误2: (Error 2:)

    Exception in thread “main” org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Browser zoom level was set to 200%. It should be set to 100%

    线程“主”中的异常org.openqa.selenium.remote.SessionNotFoundException:启动Internet Explorer发生意外错误。 浏览器缩放级别设置为200%。 应该设置为100%

    Solution: To fix the error, we need to set the Zoom level to 100% of Internet Explorer browser.

    解决方案:要解决该错误,我们需要将“缩放”级别设置为Internet Explorer浏览器的100%。

    Below are the steps to set the Zoom level to 100%.

    以下是将缩放级别设置为100%的步骤。

  • Step 1: Open Internet Explorer

    步骤1:打开Internet Explorer
  • Step 2: Go toTools menu – View – Zoom – Select 100%

    步骤2:进入“ 工具”菜单-“ 视图”-“缩放”-选择100%
  • Zoom

    Zoom

    放大

    使用Selenium WebDriver启动IE浏览器 (Launching IE browser using Selenium WebDriver)

    设置webdriver.ie.driver属性 (Setting up the webdriver.ie.driver property)

    Selenium WebDriver has a class called InternetExplorerDriver that is used to launch and control IE browser. The code to launch IE Driver is exactly the same as if you were launching a FirefoxDriver or ChromeDriver. All we need to Set a system property “webdriver.ie.driver” to the path of executable file “IEDriverServer.exe“. If you miss this, you will face an error “The path to the driver executable must be set by the webdriver.ie.driver system property“.

    Selenium WebDriver有一个称为InternetExplorerDriver的类,用于启动和控制IE浏览器。 启动IE驱动程序的代码与启动FirefoxDriver或ChromeDriver完全相同。 我们需要将一个系统属性“ webdriver.ie.driver ”设置为可执行文件“ IEDriverServer.exe ”的路径。 如果您错过了,您将遇到一个错误“ 驱动程序可执行文件的路径必须由webdriver.ie.driver系统属性设置 ”。

    
    package com.journaldev.selenium.InternetExplorer;
    
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.ie.InternetExplorerDriver;
    
    public class LaunchingIE {
    
        public static void main(String[] args) {
        System.setproperty("Webdriver.ie.driver","D:\\Drivers\\IEDriverServer.exe");
        WebDriver driver = new InternetExplorerDriver();
        driver.get("https://journaldev.com");
        String PageTitle = driver.getTitle();
        System.out.println("Page Title is:" + PageTitle);
        driver.close();
        }
     }
    

    When you run the above program you will notice that Journaldev.com is opened in the new Internet Explorer window and it will print the website title in the console.

    当您运行上述程序时,您会注意到在新的Internet Explorer窗口中打开Journaldev.com,它将在控制台中打印网站标题。

    翻译自: https://www.journaldev.com/26770/running-test-on-internet-explorer-browser

    不要运行explorer

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值