How to use Codeception & Webdriver

Bỏ codeception lâu quá gần như quên sạch. Nên thôi giờ có dịp work on it again nên write down lại để nhớ.

https://codeception.com/quickstart

https://docs.seleniumhq.org/download/

https://sites.google.com/a/chromium.org/chromedriver/downloads

Composer để install codeception

composer require codeception/codeception --dev

From now on Codeception (with installed PHPUnit) can be run as

php vendor/bin/codecept

Init

php vendor/bin/codecept bootstrap

Edit acceptant file

# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
  enabled:
  - WebDriver:
      url: 'http://localhost/phpmyadmin'
      window_size: false
      port: 9515
      browser: chrome
      capabilities:
        chromeOptions:
          binary: ''
  • Binary sẽ là path đến chrome binary
  • URL dĩ nhiên là path đến trang cần làm việc

Okay giờ cần chạy ChromeDriver trước

chromedriver --url-base=/wd/hub

Rồi chạy codeception

php vendor/bin/codecept run

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑

%d bloggers like this: