Skip to content

feat: wdio with devtools protocol #4105

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 11 commits into from
Jan 12, 2024
Merged

Conversation

kobenguyent
Copy link
Collaborator

Motivation/Description of the PR

Running with devtools protocol

{
   helpers: {
     WebDriver : {
       url: "http://localhost",
       browser: "chrome",
       devtoolsProtocol: true,
       desiredCapabilities: {
         chromeOptions: {
           args: [ "--headless", "--disable-gpu", "--no-sandbox" ]
         }
       }
     }
   }
}

Applicable helpers:

  • WebDriver

Type of change

  • 🚀 New functionality

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

@autotest-web
Copy link

Hi @kobenguyent
feat: wdio with devtools protocol #4105
can we use the codeceptjs geolocation function?

@kobenguyent
Copy link
Collaborator Author

Hi @kobenguyent feat: wdio with devtools protocol #4105 can we use the codeceptjs geolocation function?

yes that's possible when using devtools protocol -> https://github.com/codeceptjs/CodeceptJS/pull/4105/files#diff-7d8b1b9f1557e5e6307a9f1a97c1cbf9731239061de79bd62d452f39510dee65R1142

@autotest-web
Copy link

Can you please share an example, and what prerequisites are needed here?

"codeceptjs": "^3.5.11",
"webdriver": "^8.27.0",
"webdriverio": "^8.27.0"
"selenium-standalone": "9.3.1",

Capabilities set to
devtoolsProtocol: true,

@kobenguyent
Copy link
Collaborator Author

Can you please share an example, and what prerequisites are needed here?

"codeceptjs": "^3.5.11", "webdriver": "^8.27.0", "webdriverio": "^8.27.0" "selenium-standalone": "9.3.1",

Capabilities set to devtoolsProtocol: true,

sure @autotest-web once this PR is merged and released, in your WebDriver config

WebDriver : {
...
       devtoolsProtocol: true, // add this option and you're good to go with using setGeoLocation
       ...
     }

@autotest-web
Copy link

Can you please share an example, and what prerequisites are needed here?
"codeceptjs": "^3.5.11", "webdriver": "^8.27.0", "webdriverio": "^8.27.0" "selenium-standalone": "9.3.1",
Capabilities set to devtoolsProtocol: true,

sure @autotest-web once this PR is merged and released, in your WebDriver config

WebDriver : {
...
       devtoolsProtocol: true, // add this option and you're good to go with using setGeoLocation
       ...
     }

Hi @kobenguyent
It sounds good. When are you planning to release the newly added geolocation actions?

@kobenguyent
Copy link
Collaborator Author

Hey @autotest-web usually, we'd to release regularly however due to many factors that won't happen as expected. So we will announce the release once it happens.

@kobenguyent kobenguyent merged commit b42190f into 3.x Jan 12, 2024
@autotest-web
Copy link

Hi @kobenguyent
Are the geolocation actions released? Waiting eagerly

@kobenguyent kobenguyent deleted the feat-wdio-with-devtools-protocol branch January 12, 2024 11:44
@kobenguyent
Copy link
Collaborator Author

I'm eager, too.

@autotest-web
Copy link

Hey
@AutoTest-web
you could try the beta version with that feature now. https://www.npmjs.com/package/codeceptjs/v/3.5.12-beta.1

With the latest version 3.5.12-beta.1
utilizing setGeolocation, I have attempted to modify the geolocation with the
coordinates (23.128994, 113.253250).
Additionally, the WebDriver configuration includes the DevTools Protocol with the attribute
devtoolsProtocol: true.
Despite setting all the prerequisites, the location does not appear to be updated.

can you please help me here?

@kobenguyent
Copy link
Collaborator Author

Screenshot 2024-01-17 at 13 41 35
hi @autotest-web just tried and it worked for me.

@autotest-web
Copy link

autotest-web commented Jan 17, 2024

This below packages im using-
"codeceptjs": "^3.5.12-beta.1",
"webdriver": "^8.27.0",
"webdriverio": "^8.27.0"
"@wdio/cli": "7.33.0",
"@wdio/selenium-standalone-service": "^7.33.0",
"devtools": "^8.27.0",

WebDriver config set-
exports.config = {
tests: "./*_test.js",
output: "./output",
helpers: {
WebDriver: {
url: prop.url,
browser: prop.browser,
devtoolsProtocol: true,

Set geolocation -
await I.setGeoLocation(23.128994, 113.253250)

image

if u see in ss url not update with coordinates (23.128994, 113.253250).
image

Is there anything I missed in the listed packages?

@autotest-web
Copy link

This below packages im using- "codeceptjs": "^3.5.12-beta.1", "webdriver": "^8.27.0", "webdriverio": "^8.27.0" "@wdio/cli": "7.33.0", "@wdio/selenium-standalone-service": "^7.33.0", "devtools": "^8.27.0",

WebDriver config set- exports.config = { tests: "./*_test.js", output: "./output", helpers: { WebDriver: { url: prop.url, browser: prop.browser, devtoolsProtocol: true,

Set geolocation - await I.setGeoLocation(23.128994, 113.253250)

image if u see in ss url not update with coordinates (23.128994, 113.253250). image

Is there anything I missed in the listed packages?

I want to set the geolocation to China. If the location is set to China, then URL should change from .com to .cn, which is not currently happening.

@kobenguyent
Copy link
Collaborator Author

Screenshot 2024-01-18 at 07 45 37
I don't know if the url should change to .cn but at least for me, the geolocation is set as expected.

@autotest-web
Copy link

Screenshot 2024-01-18 at 07 45 37 I don't know if the url should change to .cn but at least for me, the geolocation is set as expected.

I have different URLs, and I need to check whether based on location has changed or not .

@autotest-web
Copy link

autotest-web commented Jan 18, 2024

@kobenguyent
Now, the geolocation is set as expected. I appreciate your help.
Thank you!!
image

Is there a way to simulate location changes for testing URLs by mocking the location?
I'm trying to set the geolocation to test different scenarios for various countries. If I set the location to China, the URL changes to end with '.cn'

@kobenguyent
Copy link
Collaborator Author

Nice! Glad that you made it. Regarding the url changes I think that's related to the IP detection.

@autotest-web
Copy link

Nice! Glad that you made it. Regarding the url changes I think that's related to the IP detection.

Is it possible with geolocation? We want to test based on location

@autotest-web
Copy link

Hi @kobenguyent
After adding devtoolsProtocol: true to the WebDriver configuration, I am encountering an issue where the browser window does not maximize.
Error: Command "maximizeWindow" is not supported using the Devtools protocol. You might want to use WebDriver as automation engine. For more information check out https://webdriver.io/docs/automationProtocols!
image

image

@kobenguyent
Copy link
Collaborator Author

webdriverio/webdriverio#7551 (comment)

Per wdio, there is no chance to implement this command using DevTools and Puppeteer (which drivers CDP).

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants