【问题标题】:Why I have different results in browsers 'Chrome' and 'Internet Explorer'?为什么我在浏览器“Chrome”和“Internet Explorer”中有不同的结果?
【发布时间】:2015-10-11 23:26:35
【问题描述】:

我正在使用量角器进行 e2e 测试,但我遇到了奇怪的问题。我的测试在“Chrome”上运行良好,但是当我选择“Internet Explorer”时,一些对象没有找到,我的测试失败了。为什么?我可以用它做什么?

失败的规范示例:

describe('ps-grid-column-filter-range_spec_1.1.a', function() {

var config = browser.params;

var req = config.req_lib_filter;
require(req);

var tester_column_number = config.column_number_filter;                                         
var tester_url = config.url_filter;

var filter_field = element(by.xpath("//td[@class='ng-scope n-grid__filter']["+ tester_column_number +"]"));          
var balloon_info = $('div[class="n-balloon n-balloon_bottom_left n-balloon_can_close n-balloon_info"]');                            

beforeEach(function() {
    browser.get(tester_url);
});


it('balloon should contain text',function(){                                                
    filter_field.click();                                                                   
    browser.sleep(3000);                                                                    
    var balloon_text = (balloon_info.element(by.css('div'))).element(by.css('span'));   
    var height = balloon_info.getAttribute("style");
    expect(height).toContain("height: 50px;");                                              
    expect(balloon_text.getText()).toContain('Допустимо вводить диапазон от');              
    expect(balloon_text.getText()).toContain('Например:');                                                                               
    if (true) console.log("ps-grid-column-filter-range_spec_1.1.a : text1");      


  }); 

it('should show balloon',function(){                                                        
    filter_field.click();                                                                   
    browser.sleep(3000);                                                                    
    if (balloon_info.isPresent()) expect(balloon_info.isDisplayed()).toBe(true);            
    else expect(true).toBe(false);                                                          
    if (true) console.log("ps-grid-column-filter-range_spec_1.1.a : text2");      

}); 
 });

在“Chrome”中没问题,但在“Internet Explorer”中出现错误:

NoSuchElementError: No element found using locator BycssSelector("div[class="n-balloon n-balloon_bottom_left n-balloon_can_close n-balloon_info"]")

【问题讨论】:

  • 什么版本的IE,什么版本的量角器和webdriver?我的疯狂猜测是您使用的选择器在 IE 中不起作用
  • @maurycy IE 版本:9;量角器:2.1.0;网络驱动程序:V2.45.0。但是,很遗憾,我无法更改浏览器版本...
  • 很可能是css选择器
  • 能否在问题描述中添加失败规范的示例?
  • @Michael Radionov 是的。我做到了。

标签: angularjs google-chrome internet-explorer browser protractor


【解决方案1】:

对于 IE,你应该做一些额外的事情来让事情正常工作。

在你的情况下,我会尝试以下方法:

  • 添加一个显式等待而不是browser.sleep()

    filter_field.click(); 
    
    var EC = protractor.ExpectedConditions;
    browser.wait(balloon_info, 5000);
    
  • 通过javascript点击过滤器:

    browser.executeScript("arguments[0].click();", filter_field);
    

【讨论】:

    猜你喜欢
    • 2017-03-31
    • 1970-01-01
    • 2015-08-17
    • 2017-07-19
    • 2015-10-19
    • 1970-01-01
    • 2016-03-12
    • 2016-08-08
    • 2019-12-24
    相关资源
    最近更新 更多