Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use firefox options for capabilities as well. #136

Merged
merged 1 commit into from Nov 17, 2014

Conversation

koichirok
Copy link
Contributor

firefox specific options (--profile, --profire-dir and --firefox) are can be used for RemoteWebDriver
(See https://code.google.com/p/selenium/wiki/DesiredCapabilities#Firefox_specific ),
I moved creating Firefox profile code from FirefoxDriverFactory to DriverOptinos and added
code to set firefox capabilities to DriverOptions.

This change makes selenese-runner to set firefox capabilities always when firefox options are specified,
but I believe this makes any negative effect since all of the web drivers other than FirefoxDriver may
ignore firefox capabilities.

@vmi vmi added this to the 1.6.1 milestone Nov 7, 2014
@vmi vmi self-assigned this Nov 7, 2014
@vmi vmi added the enhancement label Nov 7, 2014
@vmi vmi removed this from the 1.6.1 milestone Nov 7, 2014
@vmi
Copy link
Owner

vmi commented Nov 8, 2014

Hi,

firefox specific options (--profile, --profire-dir and --firefox) are can be used for RemoteWebDriver

Sorry, I cannot understand an above meaning.
Please provide a good point, a bad point, and a example of use.

@koichirok
Copy link
Contributor Author

Pros:

  • --profile and --profile-dir
    become to be able to test web sites require some custom browser setup (e.g. using client certificate) with remote firefox. useful for grid users.
  • --firefox
    I'm not sure about pros of this feature. Just selenium support this, i added support for this.

Cons:

  • described in my first post above.

@vmi
Copy link
Owner

vmi commented Nov 9, 2014

OK, sorry, it is one more question.
Is WebDriver in this situation not FirefoxDriver but RemoteDriver?
Please also give an example.

@koichirok
Copy link
Contributor Author

Yes, WebDriver is RemoteWebDriver.

  1. start selenium-server-standalone
    $ java -jar selenium-server-standalone-2.43.1.jar
  2. Run selenese-runner
    $ java -jar selenese-runner.jar -d remote --remote-browser firefox --remote-url _remote_hub_url_ --profile-dir _path_to_profile_dir_

Sample output here:

  • selenese-runner output:
    % java -jar selenese-runner.jar -d remote --remote-browser firefox --remote-url http://172.31.10.198:4444/wd/hub --profile-dir .mozilla/firefox/gnclz1c0.default Test.html
    [2014-11-10 15:49:50.563] [INFO] Start: Selenese Runner 1.6.0-SNAPSHOT
    [2014-11-10 15:50:36.948] [INFO] Session ID: 63242cb6-2cb6-4516-9e2c-62637f09a219
    [2014-11-10 15:50:36.948] [INFO] Initial window size: system default
    [2014-11-10 15:50:36.948] [INFO] Initialized: RemoteWebDriver
    [2014-11-10 15:50:37.627] [INFO] Start: TestSuiteTest
    [2014-11-10 15:50:37.668] [INFO] Start: TestCaseTest
    [2014-11-10 15:50:37.668] [INFO] baseURL: https://www.********.com
    [2014-11-10 15:50:37.690] [INFO] Command#1: open("/")
    [2014-11-10 15:50:41.126] [INFO] - [Success] URL: [https://www..com/****/login?p_p_id=58&p_p_lifecycle=0&_58_redirect=%2F] / Title: []
    [2014-11-10 15:50:41.126] [INFO] - Cookie: BIGipServerAG_PRODUCTION_8080=[2825983916.36895.0000](domain=www..com, path=/, expire=*)
    [2014-11-10 15:50:41.126] [INFO] - Cookie: COOKIE_SUPPORT=[true](domain=www.
    .com, path=/, expire=2015-10-24 13:02:22)
    [2014-11-10 15:50:41.126] [INFO] - Cookie: GUEST_LANGUAGE_ID=[ja_JP](domain=www..com, path=/, expire=2015-11-10 15:50:21)
    [2014-11-10 15:50:41.126] [INFO] - Cookie: JSESSIONID=[A934E4C7CF6905A942B671F8B4377D35](domain=www.
    .com, path=/, expire=*)
    [2014-11-10 15:50:41.127] [INFO] Command#2: pause("3000")
    [2014-11-10 15:50:44.240] [INFO] - [Success]
    [2014-11-10 15:50:44.242] [INFO] End(6.572sec): TestCaseTest
    [2014-11-10 15:50:44.242] [INFO] End(0.000sec): TestSuiteTest
    [2014-11-10 15:50:44.431] [INFO] Quit: RemoteWebDriver
  • selenium-server output (we can see selenium-server received filrefox_profle):
    >java -jar selenium-server-standalone-2.43.1.jar
    15:49:55.595 INFO - Launching a standalone server
    15:49:55.973 INFO - Java: Oracle Corporation 25.0-b70
    15:49:55.974 INFO - OS: Windows 7 6.1 amd64
    15:49:55.983 INFO - v2.43.1, with Core v2.43.1. Built from revision 5163bce
    15:49:56.084 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
    15:49:56.086 INFO - Version Jetty/5.1.x
    15:49:56.087 INFO - Started HttpContext[/selenium-server,/selenium-server]
    15:49:56.192 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@d7b1517
    15:49:56.193 INFO - Started HttpContext[/wd,/wd]
    15:49:56.193 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
    15:49:56.194 INFO - Started HttpContext[/,/]
    15:49:56.199 INFO - Started SocketListener on 0.0.0.0:4444
    15:49:56.199 INFO - Started org.openqa.jetty.jetty.Server@cc34f4d
    15:50:06.335 INFO - Executing: [new session: Capabilities [{browserName=firefox, version=, platform=ANY, firefox_profile=UEsDBBQACAgIADl+akUAAAAAAAAAA...}]])
    15:50:06.346 INFO - Creating a new session for Capabilities [{browserName=firefox, version=, platform=ANY, firefox_profile=UEsDBBQACAgIADl+akUAAAAAAAAAA...}]
    15:50:20.048 INFO - Done: [new session: Capabilities [{browserName=firefox, version=, platform=ANY, firefox_profile=UEsDBBQACAgIADl+akUAAAAAAAAAA...}]]
    15:50:20.079 INFO - Executing: [get current window handle])
    15:50:20.096 INFO - Done: [get current window handle]
    15:50:20.763 INFO - Executing: [get current window handle])
    15:50:20.769 INFO - Done: [get current window handle]
    15:50:20.775 INFO - Executing: [get current window handle])
    15:50:20.782 INFO - Done: [get current window handle]
    15:50:20.825 INFO - Executing: [get: https://www.********.com/])
    15:50:24.151 INFO - Done: [get: https://www.********.com/]
    15:50:24.156 INFO - Executing: [get current window handle])
    15:50:24.176 INFO - Done: [get current window handle]
    15:50:24.184 INFO - Executing: [switch to window: {3cf33828-9a30-4a4b-b518-e2f495fb1551}])
    15:50:24.191 INFO - Done: [switch to window: {3cf33828-9a30-4a4b-b518-e2f495fb1551}]
    15:50:24.196 INFO - Executing: [get current url])
    15:50:24.202 INFO - Done: [get current url]
    15:50:24.208 INFO - Executing: [get title])
    15:50:24.215 INFO - Done: [get title]
    15:50:24.222 INFO - Executing: [get all cookies])
    15:50:24.234 INFO - Done: [get all cookies]
    15:50:27.247 INFO - Executing: [get current window handle])
    15:50:27.277 INFO - Done: [get current window handle]
    15:50:27.284 INFO - Executing: [switch to window: {3cf33828-9a30-4a4b-b518-e2f495fb1551}])
    15:50:27.294 INFO - Done: [switch to window: {3cf33828-9a30-4a4b-b518-e2f495fb1551}]
    15:50:27.302 INFO - Executing: [get current url])
    15:50:27.312 INFO - Done: [get current url]
    15:50:27.320 INFO - Executing: [get title])
    15:50:27.331 INFO - Done: [get title]
    15:50:27.338 INFO - Executing: [get all cookies])
    15:50:27.351 INFO - Done: [get all cookies]
    15:50:27.379 INFO - Executing: [delete session: 63242cb6-2cb6-4516-9e2c-62637f09a219])
    15:50:27.541 INFO - Done: [delete session: 63242cb6-2cb6-4516-9e2c-62637f09a219]
    

@vmi
Copy link
Owner

vmi commented Nov 12, 2014

I would like to introduce the feature which you expect.
However, I am hard to accept your PR because it broke the responsibility of DriverOptions class.
I will think the implementation for this feature.
Please wait just a moment.

@koichirok
Copy link
Contributor Author

I see. I'll wait for your implementaiton :)

vmi added a commit that referenced this pull request Nov 15, 2014
vmi added a commit that referenced this pull request Nov 16, 2014
@vmi
Copy link
Owner

vmi commented Nov 16, 2014

I refactored as follows:

  • move processing of "firefox_binary" and "firefox_profile" to "FirefoxDriverFactory" from "DriverOptions".
  • call the processing from "RemoteWebDriverFactory" only when "--remote-browser" is "firefox".
  • send local firefox profile to remote as string by "FirefoxProfile#toJson()".

I pushed it as "koichirok-use-firefox-options-for-capabilities" branch.

@koichirok
Copy link
Contributor Author

I pushed it as "koichirok-use-firefox-options-for-capabilities" branch.

I've tested this branch and it works fine, Thx!

% java -jar selenese-runner.jar -d remote --remote-browser firefox --profile-dir gnclz1c0.default --remote-url http://172.31.10.198:4444/wd/hub/ Test.html
[2014-11-17 12:49:11.185] [INFO] Start: Selenese Runner 1.7.0-SNAPSHOT
[2014-11-17 12:49:12.032] [INFO] Remote browser: firefox
[2014-11-17 12:49:12.120] [INFO] Firefox profile directory: gnclz1c0.default
[2014-11-17 12:49:12.939] [INFO] Convert Firefox profile to JSON: 1207076 bytes
[2014-11-17 12:49:12.940] [INFO] Remote URL: http://172.31.10.198:4444/wd/hub/
[2014-11-17 12:49:33.567] [INFO] Session ID: 593b3d6e-f0fd-4f2c-8543-625871625bb1
[2014-11-17 12:49:33.568] [INFO] Initial window size: system default
[2014-11-17 12:49:33.568] [INFO] Initialized: RemoteWebDriver
[2014-11-17 12:49:36.837] [INFO] Start: TestSuite[Test] (Test.html)
[2014-11-17 12:49:36.892] [INFO] Start: TestCase[Test] (Test.html)
[2014-11-17 12:49:36.892] [INFO] baseURL: https://www.********.com
[2014-11-17 12:49:36.916] [INFO] Command#1: open("/")
[2014-11-17 12:49:39.181] [INFO] - [Success] URL: [https://www.********.com/****] / Titl
e: [********]
[2014-11-17 12:49:39.181] [INFO] - Cookie: BIGipServerAG_PRODUCTION_8080=[2825983916.36895.0000] (domain=www.********.com, path=/, expire=*)
[2014-11-17 12:49:39.182] [INFO] - Cookie: COOKIE_SUPPORT=[true] (domain=www.********.com, path=/, expire=2015-10-24 13:02:22)
[2014-11-17 12:49:39.182] [INFO] - Cookie: GUEST_LANGUAGE_ID=[ja_JP] (domain=www.********.com, path=/, expire=2015-11-17 12:49:51)
[2014-11-17 12:49:39.182] [INFO] - Cookie: JSESSIONID=[6E1BB28FC28A5D4C984082FD54A97736] (domain=www.********.com, path=/, expire=*)
[2014-11-17 12:49:39.182] [INFO] Command#2: pause("3000")
[2014-11-17 12:49:42.280] [INFO] - [Success]
[2014-11-17 12:49:42.284] [INFO] End(5.388sec): TestCase[Test] (Test.html)
[2014-11-17 12:49:42.284] [INFO] End(0.000sec): TestSuite[Test] (Test.html)
[2014-11-17 12:49:42.494] [INFO] Quit: RemoteWebDriver

@vmi vmi merged commit d8a3590 into vmi:master Nov 17, 2014
@koichirok koichirok deleted the use-firefox-options-for-capabilities branch November 18, 2014 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants