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

Bump webdriverio to v9 #4594

Merged
merged 36 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
24f7e9a
Bump webdriverio to v9
thomashohn Nov 15, 2024
4c46f29
Adjust config
thomashohn Nov 15, 2024
d5aea85
Adjust config
thomashohn Nov 15, 2024
64eaa12
Remove options
thomashohn Nov 15, 2024
400c742
Update chrome driver
thomashohn Nov 15, 2024
028efcb
Fix deprecations
thomashohn Nov 15, 2024
7217f83
Fix deprecations
thomashohn Nov 15, 2024
6513def
Merge branch '3.x' into task-4593-bump-webdriverio
thomashohn Nov 17, 2024
888caed
Fix markup
thomashohn Nov 17, 2024
a10c444
Added condition
thomashohn Nov 17, 2024
a7c7543
Fix more tests
thomashohn Nov 18, 2024
b65988b
Fix iFrame stuff
thomashohn Nov 18, 2024
8fc1284
Merge branch '3.x' into task-4593-bump-webdriverio
thomashohn Dec 12, 2024
0909608
Merge branch '3.x' into task-4593-bump-webdriverio
thomashohn Dec 18, 2024
8e42fa7
Merge branch '3.x' into task-4593-bump-webdriverio
kobenguyent Jan 2, 2025
8f8934c
Merge branch '3.x' into task-4593-bump-webdriverio
kobenguyent Jan 3, 2025
f214416
Merge branch '3.x' into task-4593-bump-webdriverio
kobenguyent Jan 3, 2025
261a22c
Merge branch '3.x' into task-4593-bump-webdriverio
thomashohn Jan 4, 2025
a531971
try to fix some wdio tests
kobenguyent Jan 6, 2025
03763cf
try to fix some wdio tests
kobenguyent Jan 6, 2025
376acdc
try to fix some wdio tests
kobenguyent Jan 6, 2025
d049c68
try to fix some wdio tests
kobenguyent Jan 6, 2025
12d97f1
try to fix some wdio tests
kobenguyent Jan 6, 2025
9842df8
try to fix some wdio tests
kobenguyent Jan 6, 2025
85f24b7
try to fix some wdio tests
kobenguyent Jan 6, 2025
5600a85
try to fix some wdio tests
kobenguyent Jan 6, 2025
a5e7d02
try to fix some wdio tests
kobenguyent Jan 6, 2025
d4132a2
try to fix some wdio tests
kobenguyent Jan 6, 2025
3ac21d7
try to fix some wdio tests
kobenguyent Jan 6, 2025
2b39c61
try to fix some wdio tests
kobenguyent Jan 6, 2025
965af2e
Try to fix popup test
thomashohn Jan 6, 2025
17cb577
Try to fix window size #resizeWindow
thomashohn Jan 6, 2025
3f1680c
Another fix
thomashohn Jan 6, 2025
62d705e
Fix popup tests
thomashohn Jan 6, 2025
7902bb1
Enable should be authenticated
thomashohn Jan 6, 2025
bb4c3ca
Trigger Build
thomashohn Jan 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions .github/workflows/webdriver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,30 @@ env:

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]

steps:
- run: docker run -d --net=host --shm-size=2g selenium/standalone-chrome:3.141.0
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: npm install
run: |
npm i --force
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: start a server
run: "php -S 127.0.0.1:8000 -t test/data/app &"
- name: run unit tests
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit
- name: run unit tests - no selenium server
run: ./node_modules/.bin/mocha test/helper/WebDriver.noSeleniumServer_test.js --exit
- name: run tests
run: "./bin/codecept.js run -c test/acceptance/codecept.WebDriver.js --grep @WebDriver --debug"

- run: docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.27
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: npm install
run: |
npm i
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: true
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
- name: start a server
run: 'php -S 127.0.0.1:8000 -t test/data/app &'
- name: run unit tests
run: ./node_modules/.bin/mocha test/helper/WebDriver_test.js --exit
- name: run tests
run: './bin/codecept.js run -c test/acceptance/codecept.WebDriver.js --grep @WebDriver --debug'
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default [
'prefer-const': 0,
'no-extra-semi': 0,
'max-classes-per-file': 0,
'no-return-await': 0,
},
},
]
41 changes: 21 additions & 20 deletions lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ class WebDriver extends Helper {
this.isRunning = false
return this.browser.deleteSession()
}
if (this.browser.isInsideFrame) await this.browser.switchToFrame(null)
if (this.browser.isInsideFrame) await this.browser.switchFrame(null)

if (this.options.keepBrowserState) return

Expand Down Expand Up @@ -1898,23 +1898,21 @@ class WebDriver extends Helper {
* libraries](http://jster.net/category/windows-modals-popups).
*/
async acceptPopup() {
return this.browser.getAlertText().then(res => {
if (res !== null) {
return this.browser.acceptAlert()
}
})
const text = await this.browser.getAlertText()
if (text) {
return await this.browser.acceptAlert()
}
}

/**
* Dismisses the active JavaScript popup, as created by `window.alert|window.confirm|window.prompt`.
*
*/
async cancelPopup() {
return this.browser.getAlertText().then(res => {
if (res !== null) {
return this.browser.dismissAlert()
}
})
const text = await this.browser.getAlertText()
if (text) {
return await this.browser.dismissAlert()
}
}

/**
Expand All @@ -1924,7 +1922,7 @@ class WebDriver extends Helper {
* @param {string} text value to check.
*/
async seeInPopup(text) {
return this.browser.getAlertText().then(res => {
return await this.browser.getAlertText().then(res => {
if (res === null) {
throw new Error('Popup is not opened')
}
Expand Down Expand Up @@ -2514,17 +2512,14 @@ class WebDriver extends Helper {
*/
async switchTo(locator) {
this.browser.isInsideFrame = true
if (Number.isInteger(locator)) {
return this.browser.switchToFrame(locator)
}
if (!locator) {
return this.browser.switchToFrame(null)
return this.browser.switchFrame(null)
}

let res = await this._locate(locator, true)
assertElementExists(res, locator)
res = usingFirstElement(res)
return this.browser.switchToFrame(res)
return this.browser.switchFrame(res)
}

/**
Expand Down Expand Up @@ -2824,7 +2819,7 @@ async function proceedSeeField(assertType, field, value) {
const fieldResults = toArray(
await forEachAsync(fields, async el => {
const elementId = getElementId(el)
return this.browser.isW3C ? el.getValue() : this.browser.getElementAttribute(elementId, 'value')
return this.browser.getElementAttribute(elementId, 'value')
}),
)

Expand All @@ -2850,15 +2845,21 @@ async function proceedSeeField(assertType, field, value) {
const filterSelectedByValue = async (elements, value) => {
return filterAsync(elements, async el => {
const elementId = getElementId(el)
const currentValue = this.browser.isW3C ? await el.getValue() : await this.browser.getElementAttribute(elementId, 'value')
const currentValue = await this.browser.getElementAttribute(elementId, 'value')
const isSelected = await this.browser.isElementSelected(elementId)
return currentValue === value && isSelected
})
}

const tag = await elem.getTagName()
if (tag === 'select') {
const subOptions = await this.browser.findElementsFromElement(elemId, 'css', 'option')
let subOptions

try {
subOptions = await this.browser.findElementsFromElement(elemId, 'css', 'option')
} catch (e) {
subOptions = await this.browser.findElementsFromElement(elemId, 'xpath', 'option')
}

if (value === '') {
// Don't filter by value
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"test-app:stop": "kill -9 $(lsof -t -i:8000)",
"test:unit:webbapi:playwright": "mocha test/helper/Playwright_test.js",
"test:unit:webbapi:puppeteer": "mocha test/helper/Puppeteer_test.js",
"test:unit:webbapi:webDriver": "mocha test/helper/WebDriver_test.js",
"test:unit:webbapi:webDriver:noSeleniumServer": "mocha test/helper/WebDriver.noSeleniumServer_test.js",
"test:unit:webbapi:webDriver": "mocha test/helper/WebDriver_test.js --timeout 10000",
"test:unit:webbapi:webDriver:noSeleniumServer": "mocha test/helper/WebDriver.noSeleniumServer_test.js --timeout 10000",
"test:unit:webbapi:testCafe": "mocha test/helper/TestCafe_test.js",
"test:unit:expect": "mocha test/helper/Expect_test.js",
"test:plugin": "mocha test/plugin/plugin_test.js",
Expand Down Expand Up @@ -168,7 +168,7 @@
"typedoc-plugin-markdown": "4.4.1",
"typescript": "5.7.2",
"wdio-docker-service": "1.5.0",
"webdriverio": "8.40.6",
"webdriverio": "^9.5.1",
"xml2js": "0.6.2",
"xpath": "0.0.34"
},
Expand Down
12 changes: 6 additions & 6 deletions test/acceptance/codecept.WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const TestHelper = require('../support/TestHelper')

module.exports.config = {
tests: './*_test.js',
timeout: 10000,
timeout: 20,
output: './output',
helpers: {
WebDriver: {
Expand All @@ -11,11 +11,11 @@ module.exports.config = {
host: TestHelper.seleniumHost(),
port: TestHelper.seleniumPort(),
// disableScreenshots: true,
// desiredCapabilities: {
// chromeOptions: {
// args: ['--headless', '--disable-gpu', '--window-size=1280,1024'],
// },
// },
desiredCapabilities: {
chromeOptions: {
args: ['--headless', '--disable-gpu', '--window-size=500,700'],
},
},
},
ScreenshotSessionHelper: {
require: '../support/ScreenshotSessionHelper.js',
Expand Down
24 changes: 12 additions & 12 deletions test/acceptance/session_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ const { event } = codeceptjs

Feature('Session')

Scenario('simple session @WebDriverIO @Puppeteer @Playwright', ({ I }) => {
Scenario('simple session @Puppeteer @Playwright', ({ I }) => {
I.amOnPage('/info')
session('john', () => {
I.amOnPage('https://codecept.io/')
I.amOnPage('/login')
I.dontSeeInCurrentUrl('/info')
I.see('CodeceptJS')
I.see('Email')
})
I.dontSee('GitHub')
I.dontSee('Email')
I.seeInCurrentUrl('/info')
})

Scenario('screenshots reflect the current page of current session @Puppeteer @Playwright @WebDriver', async ({ I }) => {
Scenario('screenshots reflect the current page of current session @Puppeteer @Playwright', async ({ I }) => {
I.amOnPage('/')
I.saveScreenshot('session_default_1.png')

Expand Down Expand Up @@ -77,7 +77,7 @@ Scenario('Different cookies for different sessions @Playwright @Puppeteer', asyn
I.expectNotEqual(cookies.john, cookies.mary)
})

Scenario('should save screenshot for sessions @WebDriverIO @Puppeteer @Playwright', async function ({ I }) {
Scenario('should save screenshot for sessions @Puppeteer @Playwright', async function ({ I }) {
await I.amOnPage('/form/bug1467')
await I.saveScreenshot('original.png')
await I.amOnPage('/')
Expand All @@ -98,7 +98,7 @@ Scenario('should save screenshot for sessions @WebDriverIO @Puppeteer @Playwrigh
await I.expectNotEqual(main_original, session_failed)
})

Scenario('should throw exception and close correctly @WebDriverIO @Puppeteer @Playwright', ({ I }) => {
Scenario('should throw exception and close correctly @Puppeteer @Playwright', ({ I }) => {
I.amOnPage('/form/bug1467#session1')
I.checkOption('Yes')
session('john', () => {
Expand All @@ -110,7 +110,7 @@ Scenario('should throw exception and close correctly @WebDriverIO @Puppeteer @Pl
I.amOnPage('/info')
}).fails()

Scenario('async/await @WebDriverIO', ({ I }) => {
Scenario('async/await', ({ I }) => {
I.amOnPage('/form/bug1467#session1')
I.checkOption('Yes')
session('john', async () => {
Expand All @@ -121,7 +121,7 @@ Scenario('async/await @WebDriverIO', ({ I }) => {
I.seeCheckboxIsChecked({ css: 'input[value=Yes]' })
})

Scenario('exception on async/await @WebDriverIO @Puppeteer @Playwright', ({ I }) => {
Scenario('exception on async/await @Puppeteer @Playwright', ({ I }) => {
I.amOnPage('/form/bug1467#session1')
I.checkOption('Yes')
session('john', async () => {
Expand All @@ -132,7 +132,7 @@ Scenario('exception on async/await @WebDriverIO @Puppeteer @Playwright', ({ I })
I.seeCheckboxIsChecked({ css: 'input[value=Yes]' })
}).throws(/to be checked/)

Scenario('should work with within @WebDriverIO @Puppeteer @Playwright', ({ I }) => {
Scenario('should work with within @Puppeteer @Playwright', ({ I }) => {
I.amOnPage('/form/bug1467')
session('john', () => {
I.amOnPage('/form/bug1467')
Expand Down Expand Up @@ -209,7 +209,7 @@ xScenario('should start firefox', async ({ I }) => {
assert(isChrome)
})

Scenario('should return a value in @WebDriverIO @Puppeteer @Playwright', async ({ I }) => {
Scenario('should return a value in @Puppeteer @Playwright', async ({ I }) => {
I.amOnPage('/form/textarea')
const val = await session('john', () => {
I.amOnPage('/info')
Expand All @@ -220,7 +220,7 @@ Scenario('should return a value in @WebDriverIO @Puppeteer @Playwright', async (
I.see('[description] => Information')
})

Scenario('should return a value @WebDriverIO @Puppeteer @Playwright in async', async ({ I }) => {
Scenario('should return a value @Puppeteer @Playwright in async', async ({ I }) => {
I.amOnPage('/form/textarea')
const val = await session('john', async () => {
I.amOnPage('/info')
Expand Down
2 changes: 1 addition & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ services:
- node_modules:/node_modules

selenium.chrome:
image: selenium/standalone-chrome:3.141.59-oxygen
image: selenium/standalone-chrome:4.26
shm_size: 2g
ports:
- 4444:4444
Expand Down
1 change: 1 addition & 0 deletions test/helper/WebDriver.noSeleniumServer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ describe('WebDriver - No Selenium server started', function () {
})
})


describe('#seeTitleEquals', () => {
it('should check that title is equal to provided one', async () => {
await wd.amOnPage('/')
Expand Down
Loading
Loading