2017-12-14 1 views
1

내 페이지에 단추가 있습니다. 각도기를 사용하여 e2e 테스트를 작성하고 싶습니다. 구현하고자하는 것은 버튼을 클릭 할 때 페이지가 http://localhost:8100/#/booking으로 변경된다는 것입니다. 어떻게 구현할 수 있습니까?각도기가 특정 URL이있는 페이지로 바로 연결될 것을 기대합니다

describe('booking function', function() { 
    it('should go to booking page', function() { 
    broswer.get(localHostCruises); 
    element(by.css('.button.button-stable.button-block')).click(); 
    //sudo code 
    expect(page change to "http://localhost:8100/#/book"); 
    }) 
}) 

답변

1

는이 같은 browser.getCurrentUrl() 방법, 그래서 뭔가를 사용해야합니다 :

element(by.css('.button.button-stable.button-block')).click().then(function() { 
    expect(browser.getCurrentUrl()).toEqual("http://localhost:8100/#/book"); 
}) 
1

당신은 코드 아래에이 작업을 수행 할 수 있습니다.

let targetLocation = 'your/target/location'; 

    browser.get('localHostCruises'); // Login page. 
    element(by.css('.button.button-stable.button-block')).click(); // click on button. 
    browser.setLocation(targetLocation); 

    // If Login takes some time, so wait until it's done. 
    browser.wait(() => { 
     return browser.getCurrentUrl().then((url) => { 
      let isMatch = url.match(targetLocation); 

      if (isMatch) { 
       page = new Page; // I assume you writing test cases in page object. 
      } else { 
       browser.setLocation(targetLocation); 
      } 

      return isMatch; 
     }); 
    }, 2000, 'Should throw an error message.'); 
관련 문제