Quantcast
Channel: Codeception
Viewing all 762 articles
Browse latest View live

Handling when window gets closed - selenium, webdriver

$
0
0

@tomolas wrote:

I'm testing a payment process flow.

This is the interaction overview:
- user makes his order on our site
- after selecting payment provider, new window is opened with payment providers website (this is controlled by payment provider)
- user fills out his payment details on site of payment provider
- the last button click on payment providers website causes the window to be closed (this is where the problem is)
- we get confirmation form payment provider on the background
- user is being taken back to our site

Everything works fine, except when the window gets automatically closed as the last step of the flow by payment provider. I get a warning inside selenium server:
WARN - Exception: Window not found. The browser window may have been closed.
and an error inside codeception output:
[Facebook\WebDriver\Exception\NoSuchWindowException]
Window not found. The browser window may have been closed.

I'm switching to the window of payment provider by:
$I->switchToNextTab();

The problem is caused by clicking a 'confirm' button on payment providers site which causes the window to get closed like this:
$I->click('.form-submitter'); // now the window is gone

Is there anything I can do to prevent this error?
Is there a way to expect the window to get closed?

Posts: 1

Participants: 1

Read full topic


Unit Test - Codeception - Using methods from PHPUnit

$
0
0

@anarela wrote:

Hello,

I'm new at PHPUnit and Codeception.

I've been working with codeception unit test (the ones that have both funcionalities, Codeception and Phpuni, working together). I've done some easy cases and I've used Codeception/Verify lib, it has been really useful.

The problem now is that I've been trying to use some code like this, in my Codeception test, but it keeps telling me that those methods are not recognized.

$this->call('POST', 'account/create', ['email' => 'foo@bar.com']);

$this->assertResponseOk();

$this->assertEquals('foo@bar.com', Input::get('email'));

The error I see is something like this:

Call to undefined method PaymentConditionUnitsTest::call()

The thing is that I would want to call some routes to get specific exceptions and validation errors. Is it possible to use this methods from PHPUnit test in Codeception tests?

Can anyone explain me how should I do this?

Thanks in advance.

Posts: 1

Participants: 1

Read full topic

Cant somebody help me. Yii2 Codeception Unit test config

Cannot install Codeception Addon to codeception/codeception docker image

$
0
0

@gunfrank wrote:

I need to create a modified image from the codeception/codeception docker image.

Basically I need pdo_mysql and imap php extensions installed, together with this codeception addon (https://github.com/AhmedSamy/codeception-smtp-mail).

I managed to install pdomysql and imap, but not the codeception addon.

This is how my Dockerfile looks like:

FROM codeception/codeception
RUN apt-get update && \
	apt-get install -y libc-client-dev libkrb5-dev && \
	rm -r /var/lib/apt/lists/*
RUN docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
    docker-php-ext-install \
    imap \
    pdo_mysql
WORKDIR /repo
RUN composer require ahmedsamy/codeception-smtp-mail
WORKDIR /project

Here's the last part of the output from the build, that concerns the installation of the codeception-smtp-mail addon:

Step 5/6 : RUN composer require ahmedsamy/codeception-smtp-mail
 ---> Running in 1df600e938b0
Using version ^0.6.0 for ahmedsamy/codeception-smtp-mail
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing php-imap/php-imap (2.0.8) Loading from cache
  - Installing ahmedsamy/codeception-smtp-mail (v0.6) Loading from cache
Writing lock file
Generating autoload files

Judging from the composer.json has been updated line that it was successfully required to the right place, but when I try to run codecept build from that container by executing docker-compose run --rm codecept build I get:

 [Codeception\Exception\ConfigurationException]  
  Module Smtp could not be found and loaded

Any help will be greatly appreciated.

Posts: 2

Participants: 2

Read full topic

Can I test the contollers directly using post request codeception yii2

Quickstart Guides

assertTrue is undefined

$
0
0

@geoidesic wrote:

Hi..

I’m confused about something..
I’m writing a functional test and I can do $I->seeInDatabase() but I can’t do $I->assertTrue()?
What am I missing?

Error:
[RuntimeException] Call to undefined method FunctionalTester::assertEquals

functional.suite.yml
====================
# Codeception Test Suite Configuration
#
# Suite for functional (integration) tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it

class_name: FunctionalTester
modules:
    enabled:
        - Laravel5:
            environment_file: .env.testing
        - \Helper\Functional
        - \Helper\Unit
        - Db
        - REST:
            # use /v1, not /api/v1; so that stack-trace will be shown
            url: /v1
            depends: Laravel5
    config:
      Laravel5:
        cleanup: false



EndPointsCept.php
====================
<?php
# note this must be a functional test as API tests are not DB aware
$I = new FunctionalTester($scenario);

$I->am('the api');
$I->wantTo('get a list of feeds from the db and check that each works');
$I->seeInDatabase('feeds',[]);
$feeds = [];
$count = $I->grabNumRecords('feeds');
for ($i=1; $i <= $count; $i++) {
    $feed = $I->grabRecord('feeds',['id'=>$i])['name'];
    $feeds[] = $feed;

    checkApi($feed, $I);

}

function checkApi($endpoint, $I) {
    $I->haveHttpHeader('Content-Type', 'application/json');
    $I->haveHttpHeader('Accept', 'Accept: application/json, */*; q=0.01');
    $I->sendPOST('/login', array("email"=>"me@nowhere.com","password"=>"password"));
    $I->sendGET($endpoint);
    $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
    $I->seeResponseIsJson();
    # check for success
    $I->seeResponseContainsJson(array('success'=>true));
    # check for Risk department entry
    $record = $I->grabDataFromResponseByJsonPath('$.success');
    $I->assertTrue($record);
}

Posts: 2

Participants: 2

Read full topic

Closed popup - selenium

$
0
0

@tomolas wrote:

Hello,
I'm testing a simple flow with Selenium/FacebookWebdriver where a popup window gets closed at the end - causing entire test to break.

The code is complete (the test will run) and will reproduce the error.
I'm really desperate here, any suggestions will be very much appreciated.

These are the errors I get:

Codeception error message:
[Facebook\WebDriver\Exception\NoSuchWindowException]
Window not found. The browser window may have been closed.

Selenium server output message:
WARN - Exception: Window not found. The browser window may have been closed.

This code reproduces the problem.
It consits of 3 .html files (main.html, intermediate.html, popup.html), test file (PopupCest.php) and configuration file (selenium.suite.yml).

PopupCest.php

<?php

class PopupCest
{

	public function popup(SeleniumTester $I)
	{
		$I->expectTo('Start on main page and click a link that opens a popup');
		$I->amOnPage('/main.html');
		$I->click('#main-link');

		$I->expectTo('Interact with the popup window and click the final confirmation button');
		$I->switchToNextTab();
		$I->click('#final-confirmation-button');

		$I->expectTo('Go back to intermediate window and let it do its magic');
		$I->switchToPreviousTab();
		$I->see('contents of this intermediate page');
		$I->seeInCurrentUrl('intermediate.html');
	}

}

selenium.suite.yml

class_name: SeleniumTester
modules:
  enabled:
    - WebDriver:
        url: http://localhost
        browser: firefox
    - \Helper\Selenium

main.html

<html>
<head>
    <meta charset="utf-8">
    <title>Main page - under my control</title>
    <meta name="description" content="Main page - under my control">
</head>

<body>
    <h1>Main</h1>
    <p>
        After clicking this link, "intermediate page" url is received from a backend operation in reality.
    </p>
    <br>
    <a href="intermediate.html" id="main-link">Click here to open the popup</a> <br>
</body>
</html>

intermediate.html

<html>
<head>
    <meta charset="utf-8">
    <title>External - intermediate page</title>
    <meta name="description" content="Intermediate page outside of my control">
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>

<body>
    <h1>Intermediate</h1>
    <p>
        In reality, contents of this intermediate page is fully controlled by other party - a payment processor. <br>
        It only load a javascript that opens up a popup window where user enters his payment details.
    </p>


    <script type="text/javascript">
        $(function() {
            var settings = "height=400,width=500,status=yes,dependent=no,resizable=yes";

            popup = window.open('popup.html', 'dont_know_the_name_here', settings);
            if (popup != null) {
                popup.focus();
            }
        });
    </script>
</body>
</html>

popup.html

<html>
<head>
    <meta charset="utf-8">
    <title>External - popup</title>
    <meta name="description" content="Popup page outside of my control">
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>

<body>
    <h1>Popup</h1>
    <p>
        Contents of this page is fully controlled by other party - a payment processor. <br>
        This is where user enters his payment details.
    </p>
    <p>
        e.g. <i>"After you have finished your data input, click here to:"</i> <br>
        <a href="" id="final-confirmation-button">Confirm your payment</a>
    </p>


    <script type="text/javascript">
        $(function() {
            $('#final-confirmation-button').on('click', function(e) {
                e.preventDefault();
                window.close(); // <-- this breaks it all 
            });
        });
    </script>
</body>
</html>

Thank you for your help,
Tomas

Posts: 1

Participants: 1

Read full topic


How to use Db dump file?

$
0
0

@geoidesic wrote:

I’m confused about something: the Db module. It talks about using an SQL dump but it’s not clear how this file is used?

  1. When I run things like Laravel modules grabRecord() it seems to use the actual database, not the dump.
  2. I don’t have a dump file and grabRecord() still works
  3. How is one supposed to create the dump file: automatically or manually? (If it’s manual then it will often be out of date).
  4. What is it used for?

Posts: 2

Participants: 2

Read full topic

How to use the Firefox Marionette Driver with php codeception

$
0
0

@Krupa_Nanda wrote:

I found many solutions that how to edit the code with these updated firefox driver but really didn't find any proper solution how to do it with php.

This is my scenario:

I run my test in Browser stack. This is my acceptance.suite.yml file

class_name: AcceptanceTester
modules:
enabled:
- \Helper\Acceptance
- WPWebDriver
config:
WPWebDriver:
host: 'hub-cloud.browserstack.com'
port: 80
browser: 'firefox'
url: 'Site_Url'
adminUsername: ''
adminPassword: ''
adminPath: '/wp-admin'
capabilities:
'browserstack.user': 'USER_ID'
'browserstack.key': 'USER_KEY'
'os': 'OS X'
'os_version': 'El Capitan'
'browserstack.debug': 'true'

Where do I need to place my drive file? And which should I update?

Thanks.

Posts: 1

Participants: 1

Read full topic

Running test via groups (-g) at 2.2.9 takes too long

$
0
0

@Codecepticon wrote:

So
I decided to update Codeception to latest 2.2.9 (with Selenium 3.2.0)
and now I get really long test starting if using groups.

When running tests directly by setting path to Cest file it works awesomely quick.
But I need to run it as groups cause all structure rely on it.

I'm using .phar

Posts: 2

Participants: 2

Read full topic

Steps are cut at 2.2.9

$
0
0

@Codecepticon wrote:

After updating to latest Codeception 2.2.9 (with selenium 3.2.0) I have noticed that all steps are cut and and with three dots (...).

Moreover that length of steps are different at IDE and at Jenkins.

Can I configure somewhere length of steps?

I'm using .phar

Posts: 2

Participants: 2

Read full topic

Codeception debugging in Visual Studio Code

$
0
0

@mirao wrote:

I would like to debug/trace acceptance tests (breakpoint, step etc.) in VSCode
I'm using PHP Debug extension and I'm able to debug common PHP scripts creating HTML pages.
But I'm not able to get it working for acceptance tests using WebDriver. Any thoughts how to do it ?

Regards

Mira

Posts: 1

Participants: 1

Read full topic

Acceptance test with selenium webdriver

$
0
0

@trookam wrote:

Hi!! I'm triying to write some acceptance test for a login form. I've tested my test with PhpBrowser and test is passing ok. But i've enabled WebDriver with selenium 3.3.0 server and i'm having trouble to pass the test.

Test is failing when i click on a login button to redirect to the login page. When i try to check the new url. Even i see the navigator that do the work correctly and i can see the login page, the assertion $I->canSeeInCurrentUrl('/secured/login'); is failing.

Any sugestions????

Thanks

Posts: 2

Participants: 2

Read full topic

How to debug a Guzzle error with amOnPage?

$
0
0

@geoidesic wrote:

I have defined a Functional test as follows:

$I = new FunctionalTester($scenario);
$I->amOnPage('/users/login');

This generates the error:

[GuzzleHttp\Exception\ConnectException] cURL error 28: See http://curl.haxx.se/libcurl/c/libcurl-errors.html

Error 28 is:

Operation timeout. The specified time-out period was reached according to the conditions.

I'm really not sure where to start with debugging this?

Posts: 2

Participants: 2

Read full topic


Test pauses at 'Scenario --' and doesn't work further

$
0
0

@Codecepticon wrote:

Environment:
* Linux with no UI
* Docker image for Selenium Standalone Server 3.1.0
* Codeception 2.2.9
* PHP 5.6.30
* Jenkins

  1. A lot of tests a paused like this:

Acceptance (chromeLocal) Tests (8) -------------------------
Name-of-test-TestsCest: Name-of-test-test
Signature: Path-to-cest-TestsCest:Name-of-test-Test
Test: tests/acceptance/Path-to-cest-TestsCest.php:Name-of-test-Test
Scenario --

AND nothing happens after this.
Test may stay at this point for a very long time untill I stop it.
It looks similar that browser is freezing. (I'm trying to check this version right now)

But after some time I can run test successfully :expressionless:

Posts: 1

Participants: 1

Read full topic

TimeoutException for waitForElementVisible

$
0
0

@Codecepticon wrote:

Environment:
* Linux with no UI
* Docker image for Selenium Standalone Server 3.1.0
* Codeception 2.2.9
* PHP 5.6.30
* Jenkins

I have problem with
$I->waitForElementVisible
For some tests it passes smoothly for other throws TimeoutException everytime.

Weird thing is that it works correctly when I run test locally.
So right now I think that problem could be in the environment.

Posts: 1

Participants: 1

Read full topic

UI Component Testing Suite

$
0
0

@romaninsh wrote:

I am working on an on-line platform (like packagist.org) for PHP User Interface components. To achieve compatibility, efficiency and security between components I am using Agile Toolkit.

For 3rd party developers I want UI component testing to be automated and simple to script. Perhaps connecting with a service rather then forcing everyone through the pain of setting up Selenium locally. I think that Codeception could be in the middle of it all, but I haven't figured out the right connection.

My open-source project, Agile Toolkit, implements number of desktop-level features (composition, dynamic reloading, dialogs, events) directly in PHP. It integrates into Laravel, Symfony, Yii etc and can store data in SQL or NoSQL. For a quick demo, see: http://ui.agiletoolkit.org/demos/reloading.php.

What approach you would recommend me to take? I would appreciate your advice!

Posts: 1

Participants: 1

Read full topic

Xdebug Cest gives different results

$
0
0

@marcelloh wrote:

If i simply do in a Cest file:
$I->amOnPage('/');
if will timeout when in xdebug mode after 30 seconds

This is my commandline:
php -d xdebug.remote_enable=1 -d xdebug.remote_autostart=On -d xdebug.idekey=Intellij ./vendor/codeception/codeception/codecept run

Posts: 6

Participants: 4

Read full topic

Possible to use codeception cest alike feautures in phpunittest

$
0
0

@marcelloh wrote:

I have 2 ways of testing:
- via phpunit (written by developers)
- via codeception, written by acceptance people

It would be nice if the webcontrollers could also be tested (by developers) in a Cest kind of way.

Is this possible?
(I only say the other way around, and since my PhpStorm can't handle codeception yet....)

Posts: 6

Participants: 4

Read full topic

Viewing all 762 articles
Browse latest View live


Latest Images