-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WebDriver BiDi] Add screenshot origin/format tests (#42804)
* [WebDriver BiDi] Add screenshot origin/format tests * Update webdriver/tests/bidi/browsing_context/capture_screenshot/origin.py Co-authored-by: Henrik Skupin <[email protected]> * Update webdriver/tests/bidi/browsing_context/capture_screenshot/__init__.py Co-authored-by: Henrik Skupin <[email protected]> * fix lint --------- Co-authored-by: Alex Rudenko <[email protected]> Co-authored-by: Henrik Skupin <[email protected]> Co-authored-by: Alex Rudenko <[email protected]>
- Loading branch information
1 parent
ca74d58
commit a8bb3e3
Showing
7 changed files
with
206 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
webdriver/tests/bidi/browsing_context/capture_screenshot/format.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
|
||
from webdriver.bidi.modules.browsing_context import FormatOptions | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_format_type(bidi_session, top_context, inline): | ||
await bidi_session.browsing_context.navigate( | ||
context=top_context["context"], | ||
url=inline("<div style='margin-top:2000px'>foo</div>"), | ||
wait="complete") | ||
|
||
png_screenshot = await bidi_session.browsing_context.capture_screenshot( | ||
context=top_context["context"], | ||
format=FormatOptions(type="image/png")) | ||
jpeg_screenshot = await bidi_session.browsing_context.capture_screenshot( | ||
context=top_context["context"], | ||
format=FormatOptions(type="image/jpeg")) | ||
|
||
assert png_screenshot != jpeg_screenshot | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_format_quality(bidi_session, top_context, inline): | ||
await bidi_session.browsing_context.navigate( | ||
context=top_context["context"], | ||
url=inline("<div style='margin-top:2000px'>foo</div>"), | ||
wait="complete") | ||
|
||
jpeg_quality_screenshot = await bidi_session.browsing_context.capture_screenshot( | ||
context=top_context["context"], | ||
format=FormatOptions(type="image/jpeg",quality=0.1)) | ||
jpeg_high_quality_screenshot = await bidi_session.browsing_context.capture_screenshot( | ||
context=top_context["context"], | ||
format=FormatOptions(type="image/jpeg",quality=1)) | ||
|
||
assert jpeg_quality_screenshot != jpeg_high_quality_screenshot | ||
|
||
assert len(jpeg_high_quality_screenshot) > len(jpeg_quality_screenshot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.