Selenium Web Driver [IE only] All web elements are frozen after logon

本文介绍了一个使用Selenium和Internet Explorer进行自动化测试时遇到的问题:登录后页面元素无法交互。通过调整设置解决了该问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[Environment]
Selenium version: selenium-server-2.26.0
OS: Windows 7 Ultimate (both 32 bit and 64 bit)
Browser: IE 9 and IE8
Browser version: IE9/8

[Related Issue]
Just a reference: This issue was found together with Issue4823 (http://code.google.com/p/selenium/issues/detail?id=4823). They may have some connections or not.


[What steps will reproduce the problem]
1. Use the following to create IE driver:
     --------------------------
        //Use IE driver
        File file = new File("E:/SW/Selenium/IEDriverServer32.exe");
        System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
        DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
        capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        capabilities.setCapability("ignoreProtectedModeSettings",true);
        driver = new InternetExplorerDriver(capabilities);
        baseUrl = "http://10.1.3.12/";
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

2. Use following code to open Login page, input username and password:
     --------------------------
        driver.get(baseUrl);
        driver.findElement(By.id("username")).sendKeys("admin");
        driver.findElement(By.id("password")).sendKeys("admin");

3. Use the following to click the Submit button to login.
     --------------------------
        driver.findElement(By.id("login_submit")).click();

[What is the expected output]
     After click Submit, it can logon, and all the web elements still work in logged on UI.

[What do you see instead]
     1. After click Submit button, it can logon. But all the UI elements in the logged on page are frozen. Click on any of them, no response.
     2. If use the following code to replace Steps 3 (i.e. driver.findElement(By.id("login_submit")).click()), after logon, all UI elements work as expected.
     --------------------------
        JavascriptExecutor js = (JavascriptExecutor) driver;
        js.executeScript("document.getElementById(\"login_submit\").click()",true);  

[Additional Information]
This issue does NOT occur on Firefox.

Answer:
if "UI elements in the logged on page are frozen" means "i can not interact with page manually" try set "enablePersistentHover" desired capabilities to false

The whole code

package com.example.tests;

import java.io.File;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.Select;

public class BenbriaSele01 {
    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();
    @Before
    public void setUp() throws Exception {
        
        
        //Use IE driver
        File file = new File("E:/SW/Selenium/IEDriverServer32.exe");
        System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
        DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
        capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        capabilities.setCapability("ignoreProtectedModeSettings",true);
        capabilities.setCapability("enablePersistentHover", false);
        driver = new InternetExplorerDriver(capabilities);
        

        
//        //Use Firefox
//        driver = new FirefoxDriver();

        
        baseUrl = "http://10.1.3.12/";
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        
    }

    @Test
    public void testBenbriaSele01() throws Exception {
        driver.get(baseUrl);
        driver.findElement(By.id("username")).sendKeys("admin");
        driver.findElement(By.id("password")).sendKeys("admin");
        driver.findElement(By.id("login_submit")).click();
//        JavascriptExecutor js = (JavascriptExecutor) driver;
//        js.executeScript("document.getElementById(\"login_submit\").click()",true);
    }

//    @After
//    public void tearDown() throws Exception {
//        driver.quit();
//        String verificationErrorString = verificationErrors.toString();
//        if (!"".equals(verificationErrorString)) {
//            fail(verificationErrorString);
//        }
//        System.out.println("tearDown!");
//    }

}

 


Done.

转载于:https://www.cnblogs.com/backpacker/archive/2012/11/27/2791151.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值