Chandana B
Chandana B

Reputation: 1

How to switch between ports to connect to browsers ,in spec file using protractor

I am automating custom browser, that is inside desktop application using protractor. Initially I have to connect to some port, and then later I have to switch to a custom browser running at another port in between script (spec file).

For initial connection I am mentioning the port in capabilities:

capabilities : {
        'browserName': 'chrome',
        'chromeOptions': {'debuggerAddress': '127.0.0.1:8088'}

    },

Is there a way to switch the port in between the script execution?

Upvotes: 0

Views: 129

Answers (2)

Chandana B
Chandana B

Reputation: 1

Got solution to this, by adding browser.restart() in my spec file.

Upvotes: 0

Xotabu4
Xotabu4

Reputation: 3091

Whoohaa, such a cool usage of protractor!

Try to use protractor wrapDriver() (http://www.protractortest.org/#/api?view=ProtractorBrowser.wrapDriver) function, and pass WebDriver instance of selenium-webdriver js (http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebDriver.html)

You can try to use thru constructor: new WebDriver(session, executor, opt_flow) or with static functions:

.attachToSession()

http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebDriver.html#WebDriver.attachToSession

.createSession()

http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/webdriver_exports_WebDriver.html#WebDriver.createSession

Notice, that createSession() accepts capabilities as second parameter.

Hope that some of this might help

Upvotes: 0

Related Questions