2015-05-21 30 views
-1

我在尋找隱藏元素時遇到問題。兩個瀏​​覽器並行打開,我必須在一個瀏覽器中訪問懸停元素

我必須打開舊版本登錄頁面才能訪問我的新版本(實時數據)的所有元素,但是當我嘗試訪問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 

回答

0

我想你可能有browser.switchTo()或browser.driver.switchTo(運氣),取決於如果角度存在。

我沒有這麼做過,買它可能看起來像:

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

看看是否讓你有點接近!