Codeception / module-webdriver

WebDriver module for Codeception
MIT License
36 stars 24 forks source link

How to accepts SSL Cert in firefox browser? #49

Open zeeshanyshaikh opened 6 years ago

zeeshanyshaikh commented 6 years ago

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

# paste suite config here
actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: https://zeetraining.com
            browser: firefox
            desiredCapabilities:
              acceptSslCerts: false
              acceptInsecureCerts: true
        - \Helper\Acceptance
DavertMik commented 6 years ago

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

zeeshanyshaikh commented 6 years ago

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?

DavertMik commented 6 years ago

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'
DavertMik commented 6 years ago

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.

zeeshanyshaikh commented 6 years ago

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.
zeeshanyshaikh commented 6 years ago

any update on this?

tasselchof commented 6 years ago

Parameter in suit configuration must be capabilities, not desiredCapabilities.