两个浏览器并行打开,我必须在一个浏览器中访问悬停元素

时间:2015-05-21 05:18:14

标签: protractor

我在寻找隐藏元素方面遇到了问题。

我必须打开我的旧版登录页面才能访问我的新版本的所有元素(实时数据),但是当我试图访问Firefox中较新版本的悬停元素时我会由于旧版本的登录页面仍然打开,因此获取元素不可见错误。如果我关闭旧版本页面,则无法访问包含所有元素的较新版本。

我正在尝试此代码,我可以点击打开按钮

   describe('Testing the template sorting ', function()    
   {                                       
   beforeEach(function() {

    browser.get('http:localhost:port/#/project/project0  /sites');

    });

    it('should check hover tiles open function', function() { 

    for(i=0;i<10;i++)
    {
         var elm = element.all(by.buttonText('Open')).get(i);
            browser.actions().mouseMove(elm).perform();
                        elm.click();
       element.all(by.css(".ng-isolate-scope i")).get(1).click();
    }
    });
    });
      But If I try the same code with this login operation,it is failing.



     describe('view old version Home page and to do testing', function() {
    beforeEach(function() {     
            browser.ignoreSynchronization = true;
          browser.get('http:olderversion localhost');
       });

    it('should login to  olderversion',function() {
            element(by.id('username')).sendKeys('xxxxxx');
      element(by.id('password')).sendKeys('xxxxxx');
    browser.driver.findElement(By.xpath(".//*[@id='iw_option']
    /tbody/tr/td/div/div/div/a")).click();

     });
     });



     describe('Testing the hover tile buttons ', function() {
        beforeEach(function() {
      browser.get('http:localhost:port/#/project/Test1_Project /sites');
                });

     it('should check hover tiles open function', function() {              

                  for(i=0;i<10;i++)
                   {
                var elm = element.all(by.buttonText('Open')).get(1);

                browser.actions().mouseMove(elm).perform();
                elm.click();                        
         element.all(by.css(".ng-isolate-
       copei")).get(1).click();                        
           }             
     });
    });

I get the following error,.Please suggest me to resolve this
ElementNotVisibleError: Element is not currently visible and so may not be
interacted with
 Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-2       
System info: host: 'SARVABAT1', ip: 'xxxxxx', os.name: 'Windows 7', os.ar
ch: 'xxxx', os.version: '6.1', java.version: '1.8.0_45'
Driver info: driver.version: unknown

1 个答案:

答案 0 :(得分:0)

我想你可能会对browser.switchTo()或者browser.driver.switchTo()感到满意,具体取决于是否存在角度。

我之前没有这样做,买它可能看起来像:

browser.getAllWindowHandles().then(function(handles) {
  oldWindow = handles[1];
  newWindow = handles[0];
  browser.driver.switchTo().window(newWindow).getWindowHandle();
  doStuffWithNewElements();
});

看看是否能让你更近一点!