title,body,link,tags,view_count,is_answered,score,answer_count
Codeception Acceptance Testing,"<p>If you have a test in which before the acceptance test is run you want the database changed can you do it? I don't think it's possible because I can't find a way to pass data to the amOnPage call since that is basically just opening a browser to that URL and starting a new session which inherently means it is completely disconnected from the command I run to start the test in the first place.</p>
",https://stackoverflow.com/questions/66163340/codeception-acceptance-testing,"['testing', 'codeception', 'acceptance-testing']",25,False,0,0
Codeception Acceptance Testing issue using session snapshot,"<h1>Update 10 Jun, 2021</h1>
<p>So when removing the populator from <code>codeception.yml</code> the session problem goes away.<br />
BUT: In the <code>dump.sql</code> is nothing having influence on users or sessions or cookies. There are only a few tables with demo data, and they are needed!</p>
<p>The relevant part in the file is this:</p>
<p>codeception.yml</p>
<pre><code>...
modules:
  enabled: [Db]
  config:
    Db:
      dsn: &quot;mysql:host=%HOST%;dbname=%DBNAME%&quot;
      user: &quot;root&quot;
      password: &quot;root&quot;
      populate: true
      cleanup: true
      # populator: &quot;mysql -u$user -p$password $dbname &lt; tests/codeception/_data/dump.sql&quot;
...
</code></pre>
<hr />
<h1>Original Post</h1>
<p>I think i read almost all similar reccources considering this issue, but nothing helped so far.</p>
<p>I am moving our Codeception tests on Github Actions. The whole build process is running but the acceptance tests not, because the session snapshot can't be restored.</p>
<p>The same Workflow works on a local server where i use selenium webdriver. I tried to run selenium in Actions (commented in build.yml) but that made some port problems.</p>
<p>What i'm doing in this short example is installing Joomla (works) and after that creating a Content category.</p>
<p>The second step (creating a Content category) tries to pick up the created session from the first step.</p>
<p>It's very simple and no problem locally, but on Actions the created session cannot be read.</p>
<p>The relevant report part:</p>
<pre><code>InstallCest: Install joomla
Signature: InstallCest:installJoomla
Test: tests/codeception/acceptance/install/InstallCest.php:installJoomla
... works

InstallCest: createCategory
Signature: InstallCest:createcategory
Test: tests/codeception/acceptance/install/InstallCest.php:createcategory
Scenario --
[Db] Executing Populator: `mysql -uroot -proot test &lt; tests/codeception/_data/dump.sql`
[Db] Populator Finished.
I create category &quot;test 123&quot;
Category creation in /administrator/
I open Joomla Administrator Login Page
[GET] http://127.0.0.1:8000/administrator/index.php
[Cookies] [{&quot;name&quot;:&quot;9d4bb4a09f511681369671a08beff228&quot;,&quot;value&quot;:&quot;fail5495jbd01q6dc2nm06i7gf&quot;,&quot;path&quot;:&quot;/&quot;,&quot;domain&quot;:&quot;127.0.0.1&quot;,&quot;expiry&quot;:1623346855,&quot;secure&quot;:false,&quot;httpOnly&quot;:false},{&quot;name&quot;:&quot;8b5558aac8008f05fd8f8e59a3244887&quot;,&quot;value&quot;:&quot;irhlqlj8jabat2n5746ba0sb5r&quot;,&quot;path&quot;:&quot;/&quot;,&quot;domain&quot;:&quot;127.0.0.1&quot;,&quot;expiry&quot;:1623346855,&quot;secure&quot;:false,&quot;httpOnly&quot;:false}]
[Snapshot] Restored &quot;admin&quot; session snapshot
[GET] http://127.0.0.1:8000/administrator/index.php?option=com_categories
Screenshot and page source were saved into '/home/runner/work/project_b/project_b/tests/codeception/_output/' dir
ERROR 
</code></pre>
<p>The report:</p>
<pre><code>session not created: No matching capabilities found
</code></pre>
<p>The HTML Snapshot:</p>
<pre><code>Warning: session_start(): Failed to read session data: user (path: /var/lib/php/sessions) in /home/runner/work/project_b/project_b/joomla/libraries/joomla/session/handler/native.php on line 260
Error: Failed to start application: Failed to start the session
</code></pre>
<p>The php.log part</p>
<pre><code>[Wed Jun  9 18:24:13 2021] 127.0.0.1:41972 Accepted
[Wed Jun  9 18:24:13 2021] 127.0.0.1:41972 [200]: GET /media/jui/fonts/IcoMoon.woff
[Wed Jun  9 18:24:13 2021] 127.0.0.1:41972 Closing
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41982 Accepted
[Wed Jun  9 18:24:16 2021] PHP Warning:  session_start(): Failed to read session data: user (path: /var/lib/php/sessions) in /home/runner/work/project_b/project_b/joomla/libraries/joomla/session/handler/native.php on line 260
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41982 [500]: GET /administrator/index.php
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41982 Closing
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41986 Accepted
[Wed Jun  9 18:24:16 2021] PHP Warning:  session_start(): Failed to read session data: user (path: /var/lib/php/sessions) in /home/runner/work/project_b/project_b/joomla/libraries/joomla/session/handler/native.php on line 260
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41986 [500]: GET /administrator/index.php?option=com_categories
[Wed Jun  9 18:24:16 2021] 127.0.0.1:41986 Closing 
</code></pre>
<p>I tried change the session.save_path without effect.</p>
<p>Posting relevant pieces:</p>
<p>composer.json</p>
<pre><code>{
    &quot;name&quot;: &quot;company/tests&quot;,
    &quot;description&quot;: &quot;Company Product&quot;,
    &quot;license&quot;: &quot;GPL-2.0+&quot;,
    &quot;require&quot;: {},
    &quot;require-dev&quot;: {
        &quot;codeception/codeception&quot;: &quot;^4&quot;,
        &quot;fzaninotto/faker&quot;: &quot;^1.6&quot;,
        &quot;behat/gherkin&quot;: &quot;^4.4.1&quot;,
        &quot;phing/phing&quot;: &quot;2.*&quot;,
        &quot;codeception/module-asserts&quot;: &quot;^1.3&quot;,
        &quot;codeception/module-webdriver&quot;: &quot;^1.2&quot;,
        &quot;codeception/module-filesystem&quot;: &quot;^1.0&quot;,
        &quot;codeception/module-db&quot;: &quot;^1.1&quot;
    }
}
</code></pre>
<p>build.yml</p>
<pre><code>name: Codeception Tests

on: [push]

jobs:
tests:
    runs-on: ${{ matrix.operating-system }}
    strategy:
    fail-fast: false
    matrix:
        operating-system: [ubuntu-latest]
        php: [&quot;7.4&quot;]
    name: PHP ${{ matrix.php }} Test on ${{ matrix.operating-system }}

    env:
    php-ini-values: post_max_size=32M
    DB_DATABASE: test
    DB_NAME: test
    DB_ADAPTER: mysql
    DB_USERNAME: root
    DB_PASSWORD: root
    DB_HOST: 127.0.0.1
    DB_PORT: 3306
    APP_URL: http://127.0.0.1:8000

    steps:
    - name: Checkout
        uses: actions/checkout@v2

    - name: Checkout Joomla 3
        uses: actions/checkout@v2
        with:
        repository: joomla/joomla-cms
        ref: &quot;3.9.27&quot;
        path: joomla

    - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
        php-version: ${{ matrix.php }}
        # ini-values: session.save_path=/tmp
        extensions: mbstring, intl, zip, json
        tools: composer:v2

    - name: Start MySQL
        run: |
        sudo /etc/init.d/mysql start
        mysql -e 'CREATE DATABASE test;' -uroot -proot
        mysql -e 'SHOW DATABASES;' -uroot -proot

    # Composer stuff ...

    - name: Run chromedriver
        run: nohup $CHROMEWEBDRIVER/chromedriver --url-base=/wd/hub /dev/null 2&gt;&amp;1 &amp;

    # - name: Start ChromeDriver (was a try)
    #   run: |
    #     google-chrome --version
    #     xvfb-run --server-args=&quot;-screen 0, 1280x720x24&quot; --auto-servernum \
    #     chromedriver --port=4444 --url-base=/wd/hub &amp;&gt; chromedriver.log &amp;

    - name: Run PHP webserver
        run: |
        php -S 127.0.0.1:8000 -t joomla/ &amp;&gt; php.log.txt &amp;
        sleep 1;

    - name: Install Tests
        run: |
        php vendor/bin/codecept run &quot;tests/codeception/acceptance/install/InstallCest.php&quot; -vv --html
        env:
        DB_PORT: ${{ job.services.mysql.ports[3306] }}

    - name: Upload Codeception output
        if: ${{ always() }}
        uses: actions/upload-artifact@v2
        with:
        name: codeception-results
        # path: Tests/Acceptance/_output/
        path: tests/codeception/_output/

    - name: Upload PHP log
        if: ${{ failure() }}
        uses: actions/upload-artifact@v2
        with:
        name: php-log
        path: php.log.txt
</code></pre>
<p>Acceptance Suite</p>
<pre><code>class_name: AcceptanceTester
modules:
enabled:
    - Asserts
    - JoomlaBrowser
    - Helper\Acceptance
    - DbHelper
    - Filesystem
config:
    JoomlaBrowser:
    url: &quot;http://127.0.0.1:8000/&quot;
    browser: &quot;chrome&quot;
    restart: true
    clear_cookies: true
    # window_size: 1280x1024
    window_size: false
    port: 9515
    capabilities:
        unexpectedAlertBehaviour: &quot;accept&quot;
        chromeOptions:
        args: [&quot;--headless&quot;, &quot;--disable-gpu&quot;] # Run Chrome in headless mode
        # prefs:
        #   download.default_directory: &quot;...&quot;
    username: &quot;admin&quot; # UserName for the Administrator
    password: &quot;admin&quot; # Password for the Administrator
    database host: &quot;127.0.0.1:3306&quot; # place where the Application is Hosted #server Address
    database user: &quot;root&quot; # MySQL Server user ID, usually root
    database password: &quot;root&quot; # MySQL Server password, usually empty or root
    database name: &quot;test&quot; # DB Name, at the Server
    database type: &quot;mysqli&quot; # type in lowercase one of the options: MySQL\MySQLi\PDO
    database prefix: &quot;jos_&quot; # DB Prefix for tables
    install sample data: &quot;no&quot; # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
    sample data: &quot;Default English (GB) Sample Data&quot; # Default Sample Data
    admin email: &quot;admin@mydomain.com&quot; # email Id of the Admin
    language: &quot;English (United Kingdom)&quot; # Language in which you want the Application to be Installed
    Helper\Acceptance:
    url: &quot;http://127.0.0.1:8000/&quot; # the url that points to the joomla installation at /tests/system/joomla-cms - we need it twice here
    MicrosoftEdgeInsiders: false # set this to true, if you are on Windows Insiders

error_level: &quot;E_ALL &amp; ~E_STRICT &amp; ~E_DEPRECATED&quot;
</code></pre>
<p>InstallCest.php</p>
<pre><code>&lt;?php

/**
* Install Joomla and create Category
*
* @since  3.7.3
*/
class InstallCest
{
    /**
    * Install Joomla, disable statistics and enable Error Reporting
    *
    * @param   AcceptanceTester  $I  The AcceptanceTester Object
    *
    * @since   3.7.3
    *
    * @return  void
    *
    */
    public function installJoomla(\AcceptanceTester $I)
    {
        $I-&gt;am('Administrator');
        $I-&gt;installJoomlaRemovingInstallationFolder();
        $I-&gt;doAdministratorLogin();
        $I-&gt;disableStatistics();
        $I-&gt;setErrorReportingToDevelopment();
    }

    /**
    * Just create Category
    *
    * @param   AcceptanceTester  $I  The AcceptanceTester Object
    *
    * @since   3.7.3
    *
    * @return  void
    *
    */
    public function createCategory(\AcceptanceTester $I)
    {
        $I-&gt;createCategory('test 123');
    }
}
</code></pre>
",https://stackoverflow.com/questions/67909742/codeception-acceptance-testing-issue-using-session-snapshot,"['selenium', 'joomla', 'selenium-chromedriver', 'github-actions', 'codeception']",352,False,2,0
"Codeception with Yii2, Acceptance testing : Explicit wait InvalidElementStateException","<p>I'm trying to execute an acceptance test on a form inside and Iframe.
My test seems to be a flaky test, in fact using the same configuration and same script, my test sometimes is successful and sometimes fails .
To overcome this issue I'm trying to use the Explicit waits from Codecption :<a href=""https://codeception.com/docs/modules/WebDriver#waitForElementVisible"" rel=""nofollow noreferrer"">https://codeception.com/docs/modules/WebDriver#waitForElementVisible</a>.
This condition sometimes works and sometimes, the element takes longer than 60 seconds to load.</p>
<pre><code> $testXpath1 =&quot;//input[@aria-labelledby='i1']&quot;;
 $I-&gt;waitForElement(['xpath' =&gt;$testXpath1 ], 60);
 $I-&gt;fillField(['xpath' =&gt;$iframeXpath1],'ggggggggggggg');
</code></pre>
<p>This is a sample of a successful run :</p>
<pre><code> Scenario --
    Destroying application
    Starting application
    [ConnectionWatcher] watching new connections
  [Fixtures] Loading fixtures
  [Fixtures] Done
  [TransactionForcer] watching new connections
 I am on page &quot;/#/pages/practice/iframe-form&quot;
  [GET] https://rori4.github.io/selenium-practice/#/pages/practice/iframe-form
 I switch to i frame {&quot;xpath&quot;:&quot;//iframe&quot;}
  Failed to find locator by name: Array to string conversion
  Iframe was not found by name, locating iframe by CSS or XPath
 I wait for element {&quot;xpath&quot;:&quot;//input[@aria-labelledby='i1']&quot;},60
 I fill field {&quot;xpath&quot;:&quot;//input[@aria-labelledby='i1']&quot;},&quot;ggggggggggggg&quot;
 I wait for element {&quot;xpath&quot;:&quot;//label[@for='i9']&quot;},60
 I click {&quot;xpath&quot;:&quot;//label[@for='i9']&quot;}
 I click {&quot;xpath&quot;:&quot;//div[@jsname='d9BH4c']&quot;}
 PASSED 
</code></pre>
<p>This is an example of a Failed run :</p>
<pre><code> [Facebook\WebDriver\Exception\InvalidElementStateException] Element is disabled: \&lt;input class=&quot;quantumWizTextinputPaperinputInput exportInput&quot; type=&quot;text&quot;&gt;
Scenario Steps:

     4. $I-&gt;fillField({&quot;xpath&quot;:&quot;//input[@aria-labelledby='i1']&quot;},&quot;ggggggggggggg&quot;) at tests\acceptance\IframeCest.php:19
     3. $I-&gt;waitForElement({&quot;xpath&quot;:&quot;//input[@aria-labelledby='i1']&quot;},60) at tests\acceptance\IframeCest.php:17       
     2. $I-&gt;switchToIFrame({&quot;xpath&quot;:&quot;//iframe&quot;}) at tests\acceptance\IframeCest.php:15
     1. $I-&gt;amOnPage(&quot;/#/pages/practice/iframe-form&quot;) at tests\acceptance\IframeCest.php:13
</code></pre>
<p>I'm new to Codeption with Yii2 using Selenium webdriver, I'm more familiar with SeleniumWebdriver with Python and Javascript.</p>
<p>So I wanted to know if there is a corresponding method in CopdeCetion to the wait.until using the expected conditions in Javascript or Python, because I don't want to enter a specific time ,I just want to make sure that my element is present and clickable for example :</p>
<pre><code>WebDriverWait wait = new WebDriverWait(driver, 3);
JavascriptExecutor js = ((JavascriptExecutor) driver);

//presence in DOM
wait.until(ExpectedConditions.presenceOfElement(By.id(&quot;ID&quot;)));`enter code here`
</code></pre>
",https://stackoverflow.com/questions/70321681/codeception-with-yii2-acceptance-testing-explicit-wait-invalidelementstateexc,"['php', 'selenium-webdriver', 'yii2', 'webdriverwait', 'codeception']",135,False,0,0
How can I set terraform variables in acceptance testing?,"<p>I've got the following test setup:</p>
<pre><code>func TestAccExampleThing_basic(t *testing.T) {
  /* ... potentially existing acceptance testing logic ... */

  resource.ParallelTest(t, resource.TestCase{
    /* ... existing TestCase functions ... */
    Steps: []resource.TestStep{
      /* ... existing TestStep ... */
      // step #2
      {
        ResourceName:      &quot;example_thing.test&quot;,
        ImportState:       true,
        ImportStateVerify: true,
      },
    },
  })
}
</code></pre>
<p>where <code>step #2</code> essentially runs a terraform import. How can I pass the values for terraform variables to it? E.g.,</p>
<pre><code>$ export TF_VAR_foo_id=abc123
$ terraform plan
</code></pre>
<p>and I want my test to run something like:</p>
<pre><code>$ export TF_VAR_foo_id=abc123
$ terraform import foo_provider.foo_resource foo-bar // runs as a part of step #2
</code></pre>
",https://stackoverflow.com/questions/68923411/how-can-i-set-terraform-variables-in-acceptance-testing,['terraform'],120,False,0,0
PHPSpec and Behat,"<p>I just started to learn the concept of BDD.</p>
<p>I learn PHPSpec and Behat for that, but it is not clear to my why do I need to use both. I understand that behat is for the functional/acceptance testing and PHPSpec is mainly for unit testing, but the articles and videos I found on this is basicly testing the the code twice: once with behat (with scenarios) and once with with phpspec. Can someone explain to my with easy examples what is the difference and when do I need to use behat and whan phpspec?</p>
<p>Thanks the anwers in advance,
Br.</p>
",https://stackoverflow.com/questions/69152829/phpspec-and-behat,"['php', 'unit-testing', 'testing', 'behat', 'phpspec']",142,True,0,1
Deploy a test site azure devops pipeline (LAMP),"<p>So I've been looking at getting the pipeline build for automation E2E Acceptance testing going.</p>
<p>I've been able to get the pipeline running on an agent, now the default path that the code is checked out to is</p>
<pre><code>/home/myusername/myagent/_work/1/s
</code></pre>
<p>which is <code>$(Pipeline.Workspace)</code>, and cannot be changed to custom path like <code>/var/www/html/</code> and accepts only relative path as described <a href=""https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/checkout-path.md"" rel=""nofollow noreferrer"">here</a>.</p>
<p>If I try to point the apache webroot to the above dir, I get the forbidden error. I tried</p>
<ul>
<li>running apache as the directory owner as described <a href=""https://askubuntu.com/a/164787/372069"">here</a></li>
<li>giving full <code>777</code> permission to the directory</li>
</ul>
<p>Now, how do I get apache to interact with those files or checkout the files inside the apache webroot <code>/var/www/html</code>in the first place so no additional work is required?</p>
<p>OS: Ubuntu 18</p>
",https://stackoverflow.com/questions/66584340/deploy-a-test-site-azure-devops-pipeline-lamp,"['azure-devops', 'azure-pipelines']",81,False,0,0
Why do I get the error &quot;Code uncompressed size is greater than max allowed size of 272629760&quot; only for some deployment targets?,"<p>As part of an AWS CodePipeline in an AWS CodeBuild action I deploy resources created with the Serverless Framework to a &quot;UAT&quot; (user acceptance testing) stage.
The pipeline runs in its own tooling AWS account, first deploying cross-account into a separate &quot;UAT&quot; account, then deploying cross-account into a separate &quot;Production&quot; account.</p>
<p>The first deployment to &quot;UAT&quot; completes successfully, whereas the succeeding deployment to &quot;Production&quot; fails with the error ...</p>
<pre><code>Serverless Error ----------------------------------------
 
  An error occurred: &lt;some name&gt;LambdaFunction - Resource handler returned message: &quot;Code uncompressed size is greater than max allowed size of 272629760. (Service: Lambda, Status Code: 400, Request ID: &lt;some request id&gt;, Extended Request ID: null)&quot; (RequestToken: &lt;some request token&gt;, HandlerErrorCode: InvalidRequest).
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              14.17.2
     Framework Version:         2.68.0 (local)
     Plugin Version:            5.5.1
     SDK Version:               4.3.0
     Components Version:        3.18.1
</code></pre>
<p>This started to happen, once I introduced the usage of a private Lambda Layer. The total size of all files seems way less than the maximum allowed size.</p>
<p>This question isn't so much about the actual error (there already exists a <a href=""https://stackoverflow.com/questions/69706481/my-jar-file-is-only-70mb-and-uncompressed-file-is-170mb-layer-zip-file-is-3mb-a"">similar question</a>).
I rather wonder why the behavior is inconsistent, varying with the deployment targets. Because the <a href=""https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html"" rel=""noreferrer"">limits for the Lambda Function package size</a> (including the usage of Lambda Layers) should be the same for all environments.</p>
",https://stackoverflow.com/questions/70302107/why-do-i-get-the-error-code-uncompressed-size-is-greater-than-max-allowed-size,"['aws-lambda', 'aws-cloudformation', 'serverless-framework', 'aws-codepipeline', 'aws-lambda-layers']",2867,False,5,0
How do I test a python function using Robot Framework?,"<p>I'm trying to do a simple test with Robot Framework where I test python functions and see if they give me the desired results, but I cannot find any good examples documented. I'm giving input and want the test to pass if it meets the expected output that I designate. It would be nice if it could test the return statement of the function. I know that Robot Framework is usually geared more toward acceptance testing and what I'm doing is more aligned with unit testing but it seems like something that should still work with Robot Framework.</p>
<p>Here is an example of some code:</p>
<pre><code>def init(logger_module):

        retVal = 0 # Assuming all goes well.
        #print(&quot;module_init - I am in logging module&quot;)

        global logging
        logging = logger_module

        initialize_alert_logging()

        #print(&quot;The current retVal = {}&quot;.format(retVal))
        print(retVal)

        return retVal
</code></pre>
<p>I want it to show success if retVal equals 0. Right now I'm able to run a test, but it isn't really testing the output. I think it's just showing that the function actually ran.</p>
<p>Here is my robot file:</p>
<pre><code>*** Settings ***
Library         String
Library         Collections
Library         duplicate_module_simple_logging.py

*** Variables ***
${robotVar}             FooBarBaz
${MY_DATA_TABLE_VALUES_TEMP}            {&quot;foo&quot;: &quot;this is foo&quot;, &quot;bar&quot;: &quot;this is bar&quot;}

*** Test Cases ***
Case1
    init    logger_module
</code></pre>
<p>Here is my log file showing a successful test:
<a href=""https://i.stack.imgur.com/uDmWv.png"" rel=""nofollow noreferrer""><img src=""https://i.stack.imgur.com/uDmWv.png"" alt="""" /></a></p>
",https://stackoverflow.com/questions/65711183/how-do-i-test-a-python-function-using-robot-framework,"['python', 'unit-testing', 'testing', 'robotframework', 'acceptance-testing']",650,True,0,1
