如何转到量角器中的特定链接?

时间:2015-08-03 22:47:45

标签: javascript jquery selenium protractor

我对量角器很新。我想明确告诉量角器打开一个特定的URL并做一些动作。我怎么能这样做?

这就是我现在正在做的事情。

((jasmine, driver) ->
    helpers = require(process.cwd() + '/../common/test/lib/helpers.coffee')

    timeout = helpers.defaultTimeout

    ##############  Test cases  ##################
    describe 'Going to the Connect pages and launch at dashboard', ->
        it 'Should login as admin and launch Location view', ->
            helpers.login(driver)
            expect(driver.wait ( ->
                return driver.getCurrentUrl().then (url) ->
                    return /map/.test(url) && /loc/.test(url)
            ), timeout).toBeTruthy()
        it 'should navigate to the connect page and show dashboard view', ->
            element(By.xpath("//a[@href='/connection/']")).click()
            expect(driver.wait ( ->
                return driver.getCurrentUrl().then (url) ->
                    return /dashboard/.test(url) && /conn/.test(url)
            ), timeout).toBeTruthy()

)(jasmine, browser.driver)

所以基本上我在一页中已经做了一些事情。现在,如果我想要上下文切换并转到另一个URL,我该怎么做?

谢谢,

2 个答案:

答案 0 :(得分:5)

您可以使用browser.get eg;

browser.get('http://juliemr.github.io/protractor-demo/');

参考https://github.com/angular/protractor/blob/master/docs/tutorial.md

答案 1 :(得分:1)

你应该可以用

来做
driver.get(url);

其中url是您要去的网页的链接。