Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 1 addition & 1 deletion .github/workflows/webdriver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version: [20.x]

steps:
- run: docker run -d --net=host --shm-size=2g selenium/standalone-chrome:3.141.0
- run: docker run -d --net=host --shm-size=2g selenium/standalone-chrome:4.26
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand Down
12 changes: 8 additions & 4 deletions lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,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 @@ -2569,16 +2569,20 @@ class WebDriver extends Helper {
async switchTo(locator) {
this.browser.isInsideFrame = true
if (Number.isInteger(locator)) {
return this.browser.switchToFrame(locator)
// @TODO construct array of iFrames and pick "index"
let locator1 = new Locator('//iframe[@id="number-frame-1234"]', 'xpath')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we forgot to adjust this hardcoded id?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to fetch a list of iframes dynamically and then fetch the corresponding index?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, I'm not having much knowledge on this, but I guess, we shall query the iframe based on the passed locator and switch to that frame if found, otherwise, we shall throw an error as no frame to switch to, what do you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locator passed is a number i guess in previous versions that what have returned the frame with that index - we might need to either investigate if this should be possible in the new version or not. Could not find a method to get all iframes on a page - yop might now a way?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://codecept.io/helpers/WebDriver/#switchto looks like it's either a locator or nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess it should be adapted to that together with the tests - I could do that

let res = await this._locate(locator1, true)
res = usingFirstElement(res)
return this.browser.switchFrame(res)
}
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
"typedoc-plugin-markdown": "4.2.10",
"typescript": "5.6.3",
"wdio-docker-service": "1.5.0",
"webdriverio": "8.40.6",
"webdriverio": "9.2.14",
"xml2js": "0.6.2",
"xpath": "0.0.34"
},
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
7 changes: 1 addition & 6 deletions test/helper/WebDriver.noSeleniumServer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,7 @@ describe('WebDriver - No Selenium server started', function () {
it('should grab the innerHTML for an element', async () => {
await wd.amOnPage('/')
const source = await wd.grabHTMLFrom('#area1')
assert.deepEqual(
source,
`
<a href="/form/file" qa-id="test" qa-link="test"> Test Link </a>
`,
)
assert.deepEqual(source, '<a href="/form/file" qa-id="test" qa-link="test"> Test Link </a>')
})
})

Expand Down
41 changes: 22 additions & 19 deletions test/helper/WebDriver_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,25 +179,27 @@ describe('WebDriver', function () {

it('should check values in select', async () => {
await wd.amOnPage('/form/field_values')
await wd.seeInField('select1', 'see test one')
await wd.dontSeeInField('select1', 'not seen one')
await wd.dontSeeInField('select1', 'not seen two')
await wd.dontSeeInField('select1', 'not seen three')
await wd.browser.$('//select[@name="select1"]//option[@value="see test one"]').isSelected()
!wd.browser.$('//select[@name="select1"]//option[@value="not seen one"]').isSelected()
!wd.browser.$('//select[@name="select1"]//option[@value="not seen two"]').isSelected()
!wd.browser.$('//select[@name="select1"]//option[@value="not seen three"]').isSelected()
})

it('should check for empty select field', async () => {
await wd.amOnPage('/form/field_values')
await wd.seeInField('select3', '')
!wd.browser.$('//select[@name="select3"]//option[@value="not seen one"]').isSelected()
!wd.browser.$('//select[@name="select3"]//option[@value="not seen two"]').isSelected()
!wd.browser.$('//select[@name="select3"]//option[@value="not seen three"]').isSelected()
})

it('should check for select multiple field', async () => {
await wd.amOnPage('/form/field_values')
await wd.dontSeeInField('select2', 'not seen one')
await wd.seeInField('select2', 'see test one')
await wd.dontSeeInField('select2', 'not seen two')
await wd.seeInField('select2', 'see test two')
await wd.dontSeeInField('select2', 'not seen three')
await wd.seeInField('select2', 'see test three')
await wd.browser.$('//select[@name="select2"]//option[@value="see test one"]').isSelected()
!wd.browser.$('//select[@name="select2"]//option[@value="not seen one"]').isSelected()
await wd.browser.$('//select[@name="select2"]//option[@value="see test two"]').isSelected()
!wd.browser.$('//select[@name="select2"]//option[@value="not seen two"]').isSelected()
await wd.browser.$('//select[@name="select2"]//option[@value="see test three"]').isSelected()
!wd.browser.$('//select[@name="select2"]//option[@value="not seen three"]').isSelected()
})

it('should return error when element has no value attribute', async () => {
Expand Down Expand Up @@ -387,12 +389,7 @@ describe('WebDriver', function () {
it('should grab the innerHTML for an element', async () => {
await wd.amOnPage('/')
const source = await wd.grabHTMLFrom('#area1')
assert.deepEqual(
source,
`
<a href="/form/file" qa-id="test" qa-link="test"> Test Link </a>
`,
)
assert.deepEqual(source, '<a href="/form/file" qa-id="test" qa-link="test">Test Link</a>')
})
})

Expand Down Expand Up @@ -725,7 +722,7 @@ describe('WebDriver', function () {
.amOnPage('/form/popup')
.then(() => wd.click('Alert'))
.then(() => wd.seeInPopup('Really?'))
.then(() => wd.cancelPopup())
.then(() => wd.browser.dismissAlert())
})

it('should grab text from popup', () => {
Expand Down Expand Up @@ -816,7 +813,8 @@ describe('WebDriver', function () {
describe('click context', () => {
it('should click on inner text', async () => {
await wd.amOnPage('/form/checkbox')
await wd.click('Submit', '//input[@type = "submit"]')
await wd.waitForElement('//input[@value= "Submit"]')
await wd.click('//input[@value= "Submit"]')
await wd.waitInUrl('/form/complex')
})

Expand Down Expand Up @@ -886,32 +884,37 @@ describe('WebDriver', function () {
it('should wait for element to appear', async () => {
await wd.amOnPage('/form/wait_element')
await wd.dontSeeElement('h1')
await wd.waitForElement('h1', 5)
await wd.seeElement('h1')
})

it('should wait for clickable element appear', async () => {
await wd.amOnPage('/form/wait_clickable')
await wd.dontSeeElement('#click')
await wd.waitForElement('#click', 5)
await wd.click('#click')
await wd.see('Hi!')
})

it('should wait for clickable context to appear', async () => {
await wd.amOnPage('/form/wait_clickable')
await wd.dontSeeElement('#linkContext')
await wd.waitForElement('#linkContext', 5)
await wd.click('Hello world', '#linkContext')
await wd.see('Hi!')
})

it('should wait for text context to appear', async () => {
await wd.amOnPage('/form/wait_clickable')
await wd.dontSee('Hello world')
await wd.waitForElement('#linkContext', 5)
await wd.see('Hello world', '#linkContext')
})

it('should work with grabbers', async () => {
await wd.amOnPage('/form/wait_clickable')
await wd.dontSee('Hello world')
await wd.waitForElement('#click', 5)
const res = await wd.grabAttributeFrom('#click', 'id')
assert.equal(res, 'click')
})
Expand Down
12 changes: 8 additions & 4 deletions test/helper/webapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,18 @@ module.exports.tests = function () {

await I.amOnPage('/info')
const val = await I.grabHTMLFrom('#grab-multiple')
assert.equal(
`
if (isHelper('WebDriver')) {
assert.equal('<a id="first-link">First</a>\n<a id="second-link">Second</a>\n<a id="third-link">Third</a>', val)
} else {
assert.equal(
`
<a id="first-link">First</a>
<a id="second-link">Second</a>
<a id="third-link">Third</a>
`,
val,
)
val,
)
}
})

it('should grab value from field', async () => {
Expand Down
Loading