Selenium 2.0b3 IE WebDriver, Click not firing

后端 未结 18 1964
我寻月下人不归
我寻月下人不归 2020-11-29 02:33

When using the IE driver with IE9, occasionally the Click method will only select a button, it wont do the action of the Click(). Note this only happens occasionally, so i d

18条回答
  •  旧时难觅i
    2020-11-29 02:46

    WebdriverJS

    In IE when you are attempting to perform an click() action, the URL keeps blink on status bar. It means the driver is focusing on the element and trying to perform click() action. In order to complete its click() action, i used sleep() method before and after every click action.

    Try this example.

    var webdriver = require('..'), By = webdriver.By, until = webdriver.until;
    var driver = new webdriver.Builder().usingServer().withCapabilities({'browserName': 'ie' }).build();
    
    driver.get('http://www.google.com')
    .then(function(){
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(1000 * 3);
        driver.findElement(By.name('q')).sendKeys('webdriver');
        driver.findElement(By.name('btnG')).then(function(button){
        button.click();
        });
    })
    .then(function(){
        driver.findElement(By.css('div[class="gb_Zb"] a[title="Google Apps"]')).then(function(apps){
            apps.click();       
            driver.findElements(By.css('a[class="gb_O"]')).then(function(appsList){
            console.log("apps : "+appsList.length);
            for(var i = 0; i < appsList.length; i++){
            console.log('applications : '+i);
            if(i == 5) {
            var element = appsList[i];
            driver.sleep(1000 * 5);
            driver.executeScript("var tmp = arguments[0]; tmp.click()", element);
            driver.sleep(1000 * 5);
            } } })  
        })
    })
    .then(null, function(err) {
      console.error("An error was thrown! By Promise... " + err);
    });
    driver.quit();
    

    to perform click we can use any of these, tested on IE

    element.click(); 
    driver.actions().click(element).perform();
    driver.executeScript("var tmp = arguments[0]; tmp.click()", element);
    

提交回复
热议问题