-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Adding ability to get pseudo-elements css value via getCSSProperty #7709 #11570
Adding ability to get pseudo-elements css value via getCSSProperty #7709 #11570
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to get unit tests for this.
As I wrote in PR comment. I have tried to mock window object and make it work with got, but nothing worked, no idea how to do it. |
There is no need to mock the window object. We already have some unit tests for the command which mocks the |
Nice, I'll look into it on saturday 😄 |
Ok, so I tried to make test work , but without success. When I use ReferenceError: window is not defined eval __mocks__/got.ts:207:24
205| case `/session/${sessionId}/execute/sync`: {
206| // mock execute
207| const script = Function(params.json.script)
| ^
208| const args = params.json.args.map((arg: any) => (arg && ( I tried to look for examples, I used some other window properties like window.scrollY inside my function and it worked.. but this one does not. Do I need to also add this specific function somewhere in mocks to make it work? |
@Pawel1894 for this test you can try to attach a mocked window object to the global scope, e.g. |
So i tried what you recommended, also this but with So I end up with this TypeError: Cannot read properties of undefined (reading 'padding-top')
❯ eval __mocks__/got.ts:206:24
204| case `/session/${sessionId}/execute`:
205| case `/session/${sessionId}/execute/sync`: {
206| const script = Function(params.json.script)
|
I am not sure if you need these. Instead make sure the mock ( |
@christian-bromann Tbh it have really hard time trying to understand how code in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will go ahead and merge this and will add necessary unit tests as an additional PR.
Thanks for the contribution 👍
See d68bc2e |
@christian-bromann Thx 👍 |
Proposed changes
Added possibility to select pseudo-element css value. It is not defined in Webdriver spec so I did it via browser execute and did not modify protocols.
I didn't found a way to get browser element other than passing it as argument. I also did split
getCSSProperty
to smaller functions because it was hard to understand with all the comments and pseudoElement ifs.Example usage:
Types of changes
Checklist
Further comments
I don't know how to mock window object with
got.ts
to be able to add tests for it ingetCSSProperty.test.ts
. I tried to use vitest spyOn to mock window object but it does not work.Reviewers: @webdriverio/project-committers