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

Set firefox options is not working #106

Open
laoneo opened this issue Feb 10, 2021 · 7 comments
Open

Set firefox options is not working #106

laoneo opened this issue Feb 10, 2021 · 7 comments

Comments

@laoneo
Copy link

laoneo commented Feb 10, 2021

What are you trying to achieve?

Set download options in firefox similar to what we can do with chrome. See yaml below.

What do you get instead?

Options are empty in firefox browser when I open url about:config.

Details

  • Codeception version: 4.1.17
  • PHP Version: 7.4
  • Operating System: Ubuntu 20.04 inside a docker container
  • Installation type: Composer
  • List of installed packages (composer show)
behat/gherkin                             v4.8.0               Gherkin DSL parser for PHP
codeception/codeception                   4.1.17               BDD-style testing framework
codeception/codeception-progress-reporter 4.0.3               
codeception/lib-asserts                   1.13.2               Assertion methods used by Codeception core and Asserts module
codeception/module-asserts                1.3.1                Codeception module containing various assertions
codeception/module-db                     1.1.0                DB module for Codeception
codeception/module-filesystem             1.0.3                Codeception module for testing local filesystem
codeception/module-webdriver              1.2.0                WebDriver module for Codeception
codeception/phpunit-wrapper               9.0.6                PHPUnit classes used by Codeception
codeception/stub                          3.7.0                Flexible Stub wrapper for PHPUnit's Mock Builder
doctrine/instantiator                     1.4.0                A small, lightweight utility to instantiate objects in PHP wi...
guzzlehttp/guzzle                         7.2.0                Guzzle is a PHP HTTP client library
guzzlehttp/promises                       1.4.0                Guzzle promises library
guzzlehttp/psr7                           1.7.0                PSR-7 message implementation that also provides common utilit...
hoa/consistency                           1.17.05.02           The Hoa\Consistency library.
hoa/console                               3.17.05.02           The Hoa\Console library.
hoa/event                                 1.17.01.13           The Hoa\Event library.
hoa/exception                             1.17.01.16           The Hoa\Exception library.
hoa/file                                  1.17.07.11           The Hoa\File library.
hoa/iterator                              2.17.01.10           The Hoa\Iterator library.
hoa/protocol                              1.17.01.14           The Hoa\Protocol library.
hoa/stream                                1.17.02.21           The Hoa\Stream library.
hoa/ustring                               4.17.01.16           The Hoa\Ustring library.
joomla-projects/joomla-browser            v4.0.0.x-dev b5afd92 joomla-browser Codeception Module
myclabs/deep-copy                         1.10.2               Create deep copies (clones) of your objects
nikic/php-parser                          v4.10.4              A PHP parser written in PHP
phar-io/manifest                          2.0.1                Component for reading phar.io manifest information from a PHP...
phar-io/version                           3.0.4                Library for handling version information and constraints
php-webdriver/webdriver                   1.9.0                A PHP client for Selenium WebDriver. Previously facebook/webd...
phpdocumentor/reflection-common           2.2.0                Common reflection classes used by phpdocumentor to reflect th...
phpdocumentor/reflection-docblock         5.2.2                With this component, a library can provide support for annota...
phpdocumentor/type-resolver               1.4.0                A PSR-5 based resolver of Class names, Types and Structural E...
phpspec/prophecy                          1.12.2               Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage                 9.2.5                Library that provides collection, processing, and rendering f...
phpunit/php-file-iterator                 3.0.5                FilterIterator implementation that filters files based on a l...
phpunit/php-invoker                       3.1.1                Invoke callables with a timeout
phpunit/php-text-template                 2.0.4                Simple template engine.
phpunit/php-timer                         5.0.3                Utility class for timing
phpunit/phpunit                           9.5.2                The PHP Unit Testing framework.
psr/container                             1.0.0                Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher                      1.0.0                Standard interfaces for event handling.
psr/http-client                           1.0.1                Common interface for HTTP clients
psr/http-message                          1.0.1                Common interface for HTTP messages
ralouphie/getallheaders                   3.0.3                A polyfill for getallheaders.
sebastian/cli-parser                      1.0.1                Library for parsing CLI options
sebastian/code-unit                       1.0.8                Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup        2.0.3                Looks up which function or method a line of code belongs to
sebastian/comparator                      4.0.6                Provides the functionality to compare PHP values for equality
sebastian/complexity                      2.0.2                Library for calculating the complexity of PHP code units
sebastian/diff                            4.0.4                Diff implementation
sebastian/environment                     5.1.3                Provides functionality to handle HHVM/PHP environments
sebastian/exporter                        4.0.3                Provides the functionality to export PHP variables for visual...
sebastian/global-state                    5.0.2                Snapshotting of global state
sebastian/lines-of-code                   1.0.3                Library for counting the lines of code in PHP source code
sebastian/object-enumerator               4.0.4                Traverses array structures and object graphs to enumerate all...
sebastian/object-reflector                2.0.4                Allows reflection of object attributes, including inherited a...
sebastian/recursion-context               4.0.4                Provides functionality to recursively process PHP variables
sebastian/resource-operations             3.0.3                Provides a list of PHP built-in functions that operate on res...
sebastian/type                            2.3.1                Collection of value objects that represent the types of the P...
sebastian/version                         3.0.2                Library that helps with managing the version number of Git-ho...
symfony/console                           v5.2.3               Eases the creation of beautiful and testable command line int...
symfony/css-selector                      v5.2.3               Converts CSS selectors to XPath expressions
symfony/deprecation-contracts             v2.2.0               A generic function and convention to trigger deprecation notices
symfony/event-dispatcher                  v5.2.3               Provides tools that allow your application components to comm...
symfony/event-dispatcher-contracts        v2.2.0               Generic abstractions related to dispatching event
symfony/finder                            v5.2.3               Finds files and directories via an intuitive fluent interface
symfony/polyfill-ctype                    v1.22.0              Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme            v1.22.0              Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer          v1.22.0              Symfony polyfill for intl's Normalizer class and related func...
symfony/polyfill-mbstring                 v1.22.0              Symfony polyfill for the Mbstring extension
symfony/polyfill-php73                    v1.22.0              Symfony polyfill backporting some PHP 7.3+ features to lower ...
symfony/polyfill-php80                    v1.22.0              Symfony polyfill backporting some PHP 8.0+ features to lower ...
symfony/process                           v5.2.3               Executes commands in sub-processes
symfony/service-contracts                 v2.2.0               Generic abstractions related to writing services
symfony/string                            v5.2.3               Provides an object-oriented API to strings and deals with byt...
symfony/yaml                              v5.2.3               Loads and dumps YAML files
theseer/tokenizer                         1.2.0                A small library for converting tokenized PHP source code into...
webmozart/assert                          1.9.1                Assertions to validate method input/output with nice error me...
  • Suite configuration:
class_name: AcceptanceTester
modules:
  config:
    WebDriver:
      host: 'selenium-test'
      port: 4444
      url: 'http://web-test'
      browser: 'firefox'
      restart: true
      clear_cookies: true
      window_size: 1024x1024
      capabilities:
        unexpectedAlertBehaviour: 'accept'
        'goog:chromeOptions':
          prefs:
            download.default_directory: "/tmp/tests"
        'moz:firefoxOptions':
          prefs:
            browser.download.folderList: 2
            browser.download.defaultFolder: "/tmp/tests"
            browser.download.dir: "/tmp/tests"
            browser.download.downloadDir: "/tmp/tests"
            browser.download.useDownloadDir: true
            browser.helperApps.neverAsk.openFile: "application/csv"
      username: 'admin'
      password: 'admin'
      database host: 'mysql-test'
      database user: 'root'
      database password: 'root'
      database name: 'sites'
      database type: 'mysqli'
      database prefix: 'j_'
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED"
@Naktibalda
Copy link
Member

This isn't an issue of Codeception, Codeception just passes all capabilities to php-webdriver library, php-webdriver passes them to Selenium, Selenium passes them to Firefox.

Either you are setting capabilities in incorrect way or thereis a bug somewhere (most likely in Marionette Driver).

I did a quick search and all results suggest setting download options using Firefox Profile.
https://www.toolsqa.com/selenium-webdriver/how-to-download-files-using-selenium/
https://stackoverflow.com/questions/41644381/python-set-firefox-preferences-for-selenium-download-location

I'm not familiar with Firefox profiles, but according to examples in documentation you have to create profile file and load it like this:

capabilities:
    unexpectedAlertBehaviour: 'accept'
    firefox_profile: '~/firefox-profiles/codeception-profile.zip.b64'

@laoneo
Copy link
Author

laoneo commented Feb 10, 2021

Tried that but it doesn't load the profile, I'm not the only one as you can see in the comment here Codeception/Codeception#1188 (comment). Any hint how this can be debugged why the profile is not loading?

@laoneo
Copy link
Author

laoneo commented Feb 10, 2021

So the profile is sent to selenium, but no clue where to start there debugging the issue.

@laoneo
Copy link
Author

laoneo commented Feb 10, 2021

I'm still on this one. How can I set the firefox profile in codeception as the example shows here for python https://stackoverflow.com/questions/18759762/firefox-selenium-webdriver-and-download-a-csv-file-automatically ?

@Naktibalda
Copy link
Member

Naktibalda commented Feb 10, 2021

You can set firefox_profile to instance of FirefoxProfile class in by calling _capabilities method in Acceptance helper.

https://github.com/php-webdriver/php-webdriver/blob/33284ca385542df62a15ee53cc82eef33ca0c407/lib/Firefox/FirefoxProfile.php

https://codeception.com/docs/modules/WebDriver

@laoneo
Copy link
Author

laoneo commented Feb 10, 2021

Can you confirm that firefox_profile works in your suite yaml? When I pass it then it arrives at selnium but it still uses an empty one.

@Naktibalda
Copy link
Member

I can't do that now.
Looks like a bug of Selenium or Firefox.

@Naktibalda Naktibalda transferred this issue from Codeception/Codeception Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants