The Wayback Machine - https://web.archive.org/web/20220321060309/https://github.com/SeleniumHQ/selenium/pull/8767
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

Add listener for DOM events using CDP and test #8767

Merged
merged 13 commits into from Nov 2, 2020

Conversation

raju249
Copy link
Member

@raju249 raju249 commented Oct 9, 2020

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.


await this.executeScript(mutationListener)

await connection.execute('Page.addScriptToEvaluateOnNewDocument', 4, {
Copy link
Member

@AutomatedTester AutomatedTester Oct 9, 2020

Choose a reason for hiding this comment

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

what does the 4 in this line mean. I am guessing it's some form of execution context but can we change this to not be a magic number.

sorry if you have done it this way before but it would be better to have something else for this (even if its context++

Copy link
Member Author

@raju249 raju249 Oct 9, 2020

Choose a reason for hiding this comment

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

Its a general id that cdp needs, nothing useful as such to us, but yeah, can make it like context++

const cdpConnection = await driver.createCDPConnection('page')

await driver.logMutationEvents(cdpConnection, function(event) {
console.log(event)
Copy link
Member

@AutomatedTester AutomatedTester Oct 9, 2020

Choose a reason for hiding this comment

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

we should probably assert and not just log the item

Copy link
Member Author

@raju249 raju249 Oct 9, 2020

Choose a reason for hiding this comment

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

@AutomatedTester - This is a draft, I tried changing PR to draft, could not find an option, this isnt complete yet, I am working on it with @harsha509

@harsha509 harsha509 marked this pull request as draft Oct 13, 2020
@@ -86,6 +86,8 @@ const WebSocket = require('ws')
const cdp = require('./devtools/CDPConnection')
const remote = require('./remote')
const cdpTargets = ['page', 'browser']
const fs = require('fs')
let cdpCommandId = 0
Copy link
Member

@corevo corevo Oct 20, 2020

Choose a reason for hiding this comment

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

Either use uuid, or place the integer on the driver, please don't keep it as a common running number for all connections.

Copy link
Member Author

@raju249 raju249 Oct 26, 2020

Choose a reason for hiding this comment

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

cdp API accepts integer as the value for id

So I have used a random number generator.

@raju249 raju249 marked this pull request as ready for review Oct 27, 2020
@raju249
Copy link
Member Author

@raju249 raju249 commented Oct 27, 2020

@AutomatedTester @corevo @harsha509 - This is ready to be reviewed!!

@CLAassistant
Copy link

@CLAassistant CLAassistant commented Nov 2, 2020

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
3 out of 4 committers have signed the CLA.

JS31096
AutomatedTester
raju249
Sri Harsha


Sri Harsha seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@AutomatedTester AutomatedTester merged commit dc9d019 into SeleniumHQ:trunk Nov 2, 2020
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants