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

Open
wants to merge 12 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 3 additions & 6 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 @@ -2568,17 +2568,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
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
9 changes: 2 additions & 7 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 Expand Up @@ -1018,7 +1013,7 @@ describe('WebDriver - No Selenium server started', function () {
await wd.amOnPage('/iframe')
await wd.see('Iframe test', 'h1')
await wd.dontSee('Information', 'h1')
await wd.switchTo(0)
await wd.switchTo('iframe')
await wd.see('Information', 'h1')
await wd.dontSee('Iframe test', 'h1')
})
Expand Down
43 changes: 23 additions & 20 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 Expand Up @@ -1033,7 +1036,7 @@ describe('WebDriver', function () {
await wd.amOnPage('/iframe')
await wd.see('Iframe test', 'h1')
await wd.dontSee('Information', 'h1')
await wd.switchTo(0)
await wd.switchTo('iframe')
await wd.see('Information', 'h1')
await wd.dontSee('Iframe test', 'h1')
})
Expand Down
14 changes: 9 additions & 5 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 Expand Up @@ -1307,7 +1311,7 @@ module.exports.tests = function () {

await I.amOnPage('/iframe')
await I.resizeWindow(500, 700)
await I.switchTo(0)
await I.switchTo('iframe')

const { x, y } = await I.grabPageScrollPosition()
await I.scrollTo('.sign')
Expand Down
Loading