Codeception / module-webdriver

WebDriver module for Codeception

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to accepts SSL Cert in firefox browser?

zeeshanyshaikh opened this issue · comments

What are you trying to achieve?

Automating application which accepts an SSL certificate before loading login page (2-way handshake)

What do you get instead?

Automated Firefox window is unable to fetch the SSL cert installed in browser and shows 400 error page

Provide console output if related. Use -vvv mode for more details.
20:05:57.153 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService
20:06:36.911 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.BeginSession@3f3ca0a7
20:06:36.913 INFO - /session: Executing POST on /session (handler: BeginSession)
20:06:36.917 INFO - Capabilities are: Capabilities {browserName=firefox}
20:06:36.918 INFO - Capabilities {browserName=firefox} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
20:06:36.919 INFO - Capabilities {browserName=firefox} matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
1508942197058 geckodriver INFO geckodriver 0.18.0
1508942197078 geckodriver INFO Listening on 127.0.0.1:4823
1508942197559 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe with args ["-marionette"]
1508942198172 addons.xpi WARN Error parsing extensions state: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [amIAddonManagerStartup.readStartupData]" nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: resource://gre/modules/addo
ns/XPIProvider.jsm :: loadExtensionState :: line 1554" data: no] Stack trace: loadExtensionState()@resource://gre/modules/addons/XPIProvider.jsm:1554 < getInstallState()@resource://gre/modules/addons/XPIProvider.jsm:1589 < checkForChanges()@resource://gre/modules/addons/XPIProvider.jsm:3109 < start
up()@resource://gre/modules/addons/XPIProvider.jsm:2188 < callProvider()@resource://gre/modules/AddonManager.jsm:269 < _startProvider()@resource://gre/modules/AddonManager.jsm:739 < startup()@resource://gre/modules/AddonManager.jsm:906 < startup()@resource://gre/modules/AddonManager.jsm:3090 < obser
ve()@jar:file:///C:/Program%20Files%20(x86)/Mozilla%20Firefox/omni.ja!/components/addonManager.js:65
1508942199069 Marionette INFO Enabled via --marionette
[Child 11400] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
1508942202706 Marionette INFO Listening on port 24667
1508942202906 Marionette DEBUG Register listener.js for window 4294967297
20:06:42.981 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:42.981 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing POST on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/url (handler: ServicedSession)
1508942203012 Marionette DEBUG Received DOM event "beforeunload" for "about:blank"
1508942204521 Marionette DEBUG Received DOM event "pagehide" for "about:blank"
1508942204522 Marionette DEBUG Received DOM event "unload" for "about:blank"
1508942204532 Marionette DEBUG Received DOM event "DOMContentLoaded" for "https://zeetraining.com/"
1508942204541 Marionette DEBUG Received DOM event "pageshow" for "https://zeetraining.com/"
20:06:45.112 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.113 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing POST on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/elements (handler: ServicedSession)
20:06:45.636 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.636 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing POST on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/elements (handler: ServicedSession)
20:06:45.666 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.667 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing POST on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/elements (handler: ServicedSession)
20:06:45.705 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.705 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing POST on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/elements (handler: ServicedSession)
20:06:45.740 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.GetLogTypes@d1229ec
20:06:45.741 INFO - /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/log/types: Executing GET on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/log/types (handler: GetLogTypes)
20:06:45.758 INFO - Found handler: org.openqa.selenium.remote.server.commandhandler.GetLogsOfType@752db15f
20:06:45.759 INFO - /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/log: Executing POST on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/log (handler: GetLogsOfType)
20:06:45.769 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.769 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing GET on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/screenshot (handler: ServicedSession)
20:06:45.843 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.844 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing GET on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/source (handler: ServicedSession)
20:06:45.922 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.922 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing DELETE on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605/cookie (handler: ServicedSession)
20:06:45.944 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4321fecd
20:06:45.945 INFO - Handler thread for session 33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (firefox): Executing DELETE on /session/33f7b7e9-c66b-4c63-9845-a6c7c12ec605 (handler: ServicedSession)
1508942205956 Marionette INFO New connections will no longer be accepted
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
[GFX1-]: Receive IPC close with reason=AbnormalShutdown
20:06:46.656 INFO - Removing session org.openqa.selenium.remote.server.ServicedSession@4321fecd

paste output here
image

Provide test source code if related

class FirstCest
{
    // tests
    public function checkLogin(AcceptanceTester $I)
    {
        $I->am('admin');
        $I->wantTo('login to Training');
        $I->amOnPage('/login');
        $I->fillField("#email", "zeetrainingadmin");
        $I->fillField("#password", "abc123");
        $I->click('Login');
        $I->see('Training');
    }
}

Details

  • Codeception version: 2.3.6
  • PHP Version: 7.1.6
  • Operating System: Windows 8.1 x64
  • Installation type: Composer
  • List of installed packages (composer show)
    behat/gherkin v4.4.5 Gherkin DSL parser for PHP 5.3
    codeception/codeception 2.3.6 BDD-style testing framework
    doctrine/instantiator 1.1.0 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
    facebook/webdriver 1.4.1 A PHP client for Selenium WebDriver
    guzzlehttp/guzzle 6.3.0 Guzzle is a PHP HTTP client library
    guzzlehttp/promises v1.3.1 Guzzle promises library
    guzzlehttp/psr7 1.4.2 PSR-7 message implementation that also provides common utility methods
    myclabs/deep-copy 1.7.0 Create deep copies (clones) of your objects
    phar-io/manifest 1.0.1 Component for reading phar.io manifest information from a PHP Archive (PHAR)
    phar-io/version 1.0.1 Library for handling version information and constraints
    phpdocumentor/reflection-common 1.0.1 Common reflection classes used by phpdocumentor to reflect the code structure
    phpdocumentor/reflection-docblock 4.1.1 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.
    phpdocumentor/type-resolver 0.4.0
    phpspec/prophecy v1.7.2 Highly opinionated mocking framework for PHP 5.3+
    phpunit/php-code-coverage 5.2.2 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
    phpunit/php-file-iterator 1.4.2 FilterIterator implementation that filters files based on a list of suffixes.
    phpunit/php-text-template 1.2.1 Simple template engine.
    phpunit/php-timer 1.0.9 Utility class for timing
    phpunit/php-token-stream 2.0.1 Wrapper around PHP's tokenizer extension.
    phpunit/phpunit 6.4.3 The PHP Unit Testing framework.
    phpunit/phpunit-mock-objects 4.0.4 Mock Object library for PHPUnit
    psr/http-message 1.0.1 Common interface for HTTP messages
    psr/log 1.0.2 Common interface for logging libraries
    sebastian/code-unit-reverse-lookup 1.0.1 Looks up which function or method a line of code belongs to
    sebastian/comparator 2.0.2 Provides the functionality to compare PHP values for equality
    sebastian/diff 2.0.1 Diff implementation
    sebastian/environment 3.1.0 Provides functionality to handle HHVM/PHP environments
    sebastian/exporter 3.1.0 Provides the functionality to export PHP variables for visualization
    sebastian/global-state 2.0.0 Snapshotting of global state
    sebastian/object-enumerator 3.0.3 Traverses array structures and object graphs to enumerate all referenced objects
    sebastian/object-reflector 1.1.1 Allows reflection of object attributes, including inherited and non-public ones
    sebastian/recursion-context 3.0.0 Provides functionality to recursively process PHP variables
    sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources
    sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects
    stecman/symfony-console-completion 0.7.0 Automatic BASH completion for Symfony Console Component based applications.
    symfony/browser-kit v3.3.10 Symfony BrowserKit Component
    symfony/console v3.3.10 Symfony Console Component
    symfony/css-selector v3.3.10 Symfony CssSelector Component
    symfony/debug v3.3.10 Symfony Debug Component
    symfony/dom-crawler v3.3.10 Symfony DomCrawler Component
    symfony/event-dispatcher v3.3.10 Symfony EventDispatcher Component
    symfony/finder v3.3.10 Symfony Finder Component
    symfony/polyfill-mbstring v1.6.0 Symfony polyfill for the Mbstring extension
    symfony/process v3.3.10 Symfony Process Component
    symfony/yaml v3.3.10 Symfony Yaml Component
    theseer/tokenizer 1.1.0 A small library for converting tokenized PHP source code into XML and potentially other formats
    webmozart/assert 1.2.0 Assertions to validate method input/output with nice error messages.
  • Suite configuration:
# paste suite config here
actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: https://zeetraining.com
            browser: firefox
            desiredCapabilities:
              acceptSslCerts: false
              acceptInsecureCerts: true
        - \Helper\Acceptance

Sorry, I don't know the issues of modern firefox and how it handles SSL.
Maybe there are similar issues with other testing tools? If so I could help to port their solution to your case

I got this (https://sqa.stackexchange.com/questions/13526/select-ssl-certificates-using-selenium-web-driver) and some other post similar to this (using firefox profile). But all these are in JAVA. Can you check if this can be ported?

Looks like you need to create Firefox profile and add it to capabilities list:

    modules:
       enabled:
          - WebDriver:
             url: 'http://localhost/'
             browser: firefox
             window_size: 1024x768
             capabilities:
                 firefox_profile: '~/firefox-profiles/codeception-profile.zip.b64'

If that doesn't help, you can set capabilities dynamically: http://codeception.com/docs/modules/WebDriver#_capabilities

You will need to learn how a profile can be added in facebook/php-webdriver library.

Hi, @DavertMik I did try creating firefox profile (zip.b64) and added to capabilities but getting the same issue.
I have doubt in two things:

  1. The path included in capabilities is the absolute path? I tried giving path as only file name since I stored the file in the same folder where my suite.yml is.
  2. If you have proper steps to create firefox profile and convert to base64 please let me know.

any update on this?

commented

Parameter in suit configuration must be capabilities, not desiredCapabilities.