lambdatest-playwright-driver 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.1
2
+ Name: lambdatest-playwright-driver
3
+ Version: 1.0.0
4
+ Summary: Python Playwright SDK for visual testing with Smart UI
5
+ Home-page: https://github.com/LambdaTest/lambdatest-python-sdk
6
+ Author: LambdaTest <keys@lambdatest.com>
7
+ License: MIT
8
+ Keywords: lambdatest python playwright sdk visual testing
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Natural Language :: English
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Topic :: Software Development :: Testing
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: playwright>=1.12
17
+ Requires-Dist: lambdatest-sdk-utils
18
+
19
+ # lambdatest-playwright-driver
20
+ [![SmartUI-Testing](https://smartui.lambdatest.com/static/media/LTBadge.64a05e73.svg)](https://smartui.lambdatest.com)
21
+
22
+ SmartUI SDK for python playwright
23
+ - [Installation](#installation)
24
+ - [Methods](#methods)
25
+ - [Usage](#usage)
26
+
27
+ ## Installation
28
+
29
+ Install Smart UI cli
30
+
31
+ ```sh-session
32
+ $ npm install -g @lambdatest/smartui-cli
33
+ ```
34
+
35
+ Install Python Playwright Package
36
+
37
+ ```sh-session
38
+ $ pip3 install lambdatest-playwright-driver
39
+ ```
40
+
41
+ ## Methods
42
+ ``` python
43
+ smartui_snapshot(page,"snapshotName")
44
+ ```
45
+
46
+ - `page` (**required**) - A page object instance from playwright is required.
47
+ - `snapshotName` (**required**) - Name of the screenshot
48
+
49
+ ## Usage
50
+
51
+ Example playwright test using `smartui_snapshot`
52
+
53
+ ``` python
54
+ from playwright.sync_api import sync_playwright, Playwright
55
+ from lambdatest_playwright_driver import smartui_snapshot
56
+
57
+ def run(playwright: Playwright):
58
+ webkit = playwright.webkit
59
+ browser = webkit.launch()
60
+ context = browser.new_context()
61
+ page = context.new_page()
62
+
63
+ try:
64
+ page.goto("https://www.lambdatest.com")
65
+ smartui_snapshot(page, "example_snapshot", options={})
66
+ except Exception as e:
67
+ print(f"Error occurred during SmartUI snapshot: {e}")
68
+ finally:
69
+ browser.close()
70
+
71
+ with sync_playwright() as playwright:
72
+ run(playwright)
73
+ ```
74
+
75
+
76
+ Copy the project token from [SmartUI Dashboard](https://smartui.lambdatest.com/) and set on CLI via comman
77
+ <b>For Linux/macOS:</b>
78
+
79
+ ```sh-session
80
+ export PROJECT_TOKEN="****-****-****-************"
81
+ ```
82
+
83
+ <b>For Windows:</b>
84
+
85
+ ```sh-session
86
+ set PROJECT_TOKEN="****-****-****-************"
87
+ ```
88
+
89
+ Running test
90
+ ```sh-session
91
+ $ npx smartui exec [python test command]
92
+ ```
93
+ This will create new build and upload snapshot to Smart UI Project.
94
+
95
+ Executing above test
96
+
97
+ ```sh-session
98
+ $ npx smartui exec python test.py
99
+ ✔ Authenticated with SmartUI
100
+ → using project token '******#ihcjks'
101
+ ✔ SmartUI started
102
+ → listening on port 8080
103
+ ✔ Fetched git information
104
+ → branch: main, commit: 7e336e6, author: Sushobhit Dua
105
+ ✔ SmartUI build created
106
+ → build id: ee2cb6c5-9541-494a-9c75-a74629396b80
107
+ ✔ Execution of 'python3 test.py' completed; exited with code 0
108
+ → INFO:@lambdatest/python-selenium-driver:Snapshot captured name
109
+ ✔ Finalized build
110
+
111
+ ```
112
+
113
+ ## Contribute
114
+
115
+ #### Reporting bugs
116
+
117
+ Our GitHub Issue Tracker will help you log bug reports.
118
+
119
+ Tips for submitting an issue:
120
+ Keep in mind, you don't end up submitting two issues with the same information. Make sure you add a unique input in every issue that you submit. You could also provide a "+1" value in the comments.
121
+
122
+ Always provide the steps to reproduce before you submit a bug.
123
+ Provide the environment details where you received the issue i.e. Browser Name, Browser Version, Operating System, Screen Resolution and more.
124
+ Describe the situation that led to your encounter with bug.
125
+ Describe the expected output, and the actual output precisely.
126
+
127
+ #### Pull Requests
128
+
129
+ We don't want to pull breaks in case you want to customize your LambdaTest experience. Before you proceed with implementing pull requests, keep in mind the following.
130
+ Make sure you stick to coding conventions.
131
+ Once you include tests, ensure that they all pass.
132
+ Make sure to clean up your Git history, prior your submission of a pull-request. You can do so by using the interactive rebase command for committing and squashing, simultaneously with minor changes + fixes into the corresponding commits.
133
+
134
+ ## About LambdaTest
135
+
136
+ [LambdaTest](https://www.lambdatest.com/) is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your [selenium automation testing](https://www.lambdatest.com/selenium-automation) to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.
@@ -0,0 +1,118 @@
1
+ # lambdatest-playwright-driver
2
+ [![SmartUI-Testing](https://smartui.lambdatest.com/static/media/LTBadge.64a05e73.svg)](https://smartui.lambdatest.com)
3
+
4
+ SmartUI SDK for python playwright
5
+ - [Installation](#installation)
6
+ - [Methods](#methods)
7
+ - [Usage](#usage)
8
+
9
+ ## Installation
10
+
11
+ Install Smart UI cli
12
+
13
+ ```sh-session
14
+ $ npm install -g @lambdatest/smartui-cli
15
+ ```
16
+
17
+ Install Python Playwright Package
18
+
19
+ ```sh-session
20
+ $ pip3 install lambdatest-playwright-driver
21
+ ```
22
+
23
+ ## Methods
24
+ ``` python
25
+ smartui_snapshot(page,"snapshotName")
26
+ ```
27
+
28
+ - `page` (**required**) - A page object instance from playwright is required.
29
+ - `snapshotName` (**required**) - Name of the screenshot
30
+
31
+ ## Usage
32
+
33
+ Example playwright test using `smartui_snapshot`
34
+
35
+ ``` python
36
+ from playwright.sync_api import sync_playwright, Playwright
37
+ from lambdatest_playwright_driver import smartui_snapshot
38
+
39
+ def run(playwright: Playwright):
40
+ webkit = playwright.webkit
41
+ browser = webkit.launch()
42
+ context = browser.new_context()
43
+ page = context.new_page()
44
+
45
+ try:
46
+ page.goto("https://www.lambdatest.com")
47
+ smartui_snapshot(page, "example_snapshot", options={})
48
+ except Exception as e:
49
+ print(f"Error occurred during SmartUI snapshot: {e}")
50
+ finally:
51
+ browser.close()
52
+
53
+ with sync_playwright() as playwright:
54
+ run(playwright)
55
+ ```
56
+
57
+
58
+ Copy the project token from [SmartUI Dashboard](https://smartui.lambdatest.com/) and set on CLI via comman
59
+ <b>For Linux/macOS:</b>
60
+
61
+ ```sh-session
62
+ export PROJECT_TOKEN="****-****-****-************"
63
+ ```
64
+
65
+ <b>For Windows:</b>
66
+
67
+ ```sh-session
68
+ set PROJECT_TOKEN="****-****-****-************"
69
+ ```
70
+
71
+ Running test
72
+ ```sh-session
73
+ $ npx smartui exec [python test command]
74
+ ```
75
+ This will create new build and upload snapshot to Smart UI Project.
76
+
77
+ Executing above test
78
+
79
+ ```sh-session
80
+ $ npx smartui exec python test.py
81
+ ✔ Authenticated with SmartUI
82
+ → using project token '******#ihcjks'
83
+ ✔ SmartUI started
84
+ → listening on port 8080
85
+ ✔ Fetched git information
86
+ → branch: main, commit: 7e336e6, author: Sushobhit Dua
87
+ ✔ SmartUI build created
88
+ → build id: ee2cb6c5-9541-494a-9c75-a74629396b80
89
+ ✔ Execution of 'python3 test.py' completed; exited with code 0
90
+ → INFO:@lambdatest/python-selenium-driver:Snapshot captured name
91
+ ✔ Finalized build
92
+
93
+ ```
94
+
95
+ ## Contribute
96
+
97
+ #### Reporting bugs
98
+
99
+ Our GitHub Issue Tracker will help you log bug reports.
100
+
101
+ Tips for submitting an issue:
102
+ Keep in mind, you don't end up submitting two issues with the same information. Make sure you add a unique input in every issue that you submit. You could also provide a "+1" value in the comments.
103
+
104
+ Always provide the steps to reproduce before you submit a bug.
105
+ Provide the environment details where you received the issue i.e. Browser Name, Browser Version, Operating System, Screen Resolution and more.
106
+ Describe the situation that led to your encounter with bug.
107
+ Describe the expected output, and the actual output precisely.
108
+
109
+ #### Pull Requests
110
+
111
+ We don't want to pull breaks in case you want to customize your LambdaTest experience. Before you proceed with implementing pull requests, keep in mind the following.
112
+ Make sure you stick to coding conventions.
113
+ Once you include tests, ensure that they all pass.
114
+ Make sure to clean up your Git history, prior your submission of a pull-request. You can do so by using the interactive rebase command for committing and squashing, simultaneously with minor changes + fixes into the corresponding commits.
115
+
116
+ ## About LambdaTest
117
+
118
+ [LambdaTest](https://www.lambdatest.com/) is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your [selenium automation testing](https://www.lambdatest.com/selenium-automation) to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.
@@ -0,0 +1,2 @@
1
+ from lambdatest_playwright_driver.version import __version__
2
+ from lambdatest_playwright_driver.smartui import smartui_snapshot
@@ -0,0 +1,38 @@
1
+ from lambdatest_sdk_utils import is_smartui_enabled, fetch_dom_serializer, post_snapshot # type: ignore
2
+ from lambdatest_sdk_utils import setup_logger, get_logger # type: ignore
3
+ from playwright.async_api import Page # type: ignore
4
+
5
+ def smartui_snapshot(page: Page, name: str, options={}):
6
+ # setting up logger
7
+ setup_logger()
8
+ logger = get_logger('lambdatest-playwright-driver')
9
+
10
+
11
+ if not page:
12
+ raise ValueError('A Playwright `page` object is required.')
13
+ if not name:
14
+ raise ValueError('The `snapshotName` argument is required.')
15
+ if is_smartui_enabled() is False:
16
+ raise Exception("Cannot find SmartUI server.")
17
+
18
+ try:
19
+ resp = fetch_dom_serializer()
20
+ page.evaluate(resp['data']['dom'])
21
+
22
+ dom = dict()
23
+ dom['name'] = name
24
+ dom['url'] = page.url
25
+ dom['dom'] = page.evaluate("([options]) => SmartUIDOM.serialize(options)",[options])
26
+
27
+ res = post_snapshot(dom, 'lambdatest-playwright-driver', options=options)
28
+
29
+ if res and res.get('data') and res['data'].get('warnings') and len(res['data']['warnings']) != 0:
30
+ for warning in res['data']['warnings']:
31
+ logger.warning(warning)
32
+
33
+ logger.info(f'Snapshot captured {name}')
34
+ except Exception as e:
35
+ logger.error(f"SmartUI snapshot failed '{name}'")
36
+ logger.error(e)
37
+
38
+
@@ -0,0 +1 @@
1
+ __version__ = '1.0.0'
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.1
2
+ Name: lambdatest-playwright-driver
3
+ Version: 1.0.0
4
+ Summary: Python Playwright SDK for visual testing with Smart UI
5
+ Home-page: https://github.com/LambdaTest/lambdatest-python-sdk
6
+ Author: LambdaTest <keys@lambdatest.com>
7
+ License: MIT
8
+ Keywords: lambdatest python playwright sdk visual testing
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Natural Language :: English
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Topic :: Software Development :: Testing
14
+ Requires-Python: >=3.7
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: playwright>=1.12
17
+ Requires-Dist: lambdatest-sdk-utils
18
+
19
+ # lambdatest-playwright-driver
20
+ [![SmartUI-Testing](https://smartui.lambdatest.com/static/media/LTBadge.64a05e73.svg)](https://smartui.lambdatest.com)
21
+
22
+ SmartUI SDK for python playwright
23
+ - [Installation](#installation)
24
+ - [Methods](#methods)
25
+ - [Usage](#usage)
26
+
27
+ ## Installation
28
+
29
+ Install Smart UI cli
30
+
31
+ ```sh-session
32
+ $ npm install -g @lambdatest/smartui-cli
33
+ ```
34
+
35
+ Install Python Playwright Package
36
+
37
+ ```sh-session
38
+ $ pip3 install lambdatest-playwright-driver
39
+ ```
40
+
41
+ ## Methods
42
+ ``` python
43
+ smartui_snapshot(page,"snapshotName")
44
+ ```
45
+
46
+ - `page` (**required**) - A page object instance from playwright is required.
47
+ - `snapshotName` (**required**) - Name of the screenshot
48
+
49
+ ## Usage
50
+
51
+ Example playwright test using `smartui_snapshot`
52
+
53
+ ``` python
54
+ from playwright.sync_api import sync_playwright, Playwright
55
+ from lambdatest_playwright_driver import smartui_snapshot
56
+
57
+ def run(playwright: Playwright):
58
+ webkit = playwright.webkit
59
+ browser = webkit.launch()
60
+ context = browser.new_context()
61
+ page = context.new_page()
62
+
63
+ try:
64
+ page.goto("https://www.lambdatest.com")
65
+ smartui_snapshot(page, "example_snapshot", options={})
66
+ except Exception as e:
67
+ print(f"Error occurred during SmartUI snapshot: {e}")
68
+ finally:
69
+ browser.close()
70
+
71
+ with sync_playwright() as playwright:
72
+ run(playwright)
73
+ ```
74
+
75
+
76
+ Copy the project token from [SmartUI Dashboard](https://smartui.lambdatest.com/) and set on CLI via comman
77
+ <b>For Linux/macOS:</b>
78
+
79
+ ```sh-session
80
+ export PROJECT_TOKEN="****-****-****-************"
81
+ ```
82
+
83
+ <b>For Windows:</b>
84
+
85
+ ```sh-session
86
+ set PROJECT_TOKEN="****-****-****-************"
87
+ ```
88
+
89
+ Running test
90
+ ```sh-session
91
+ $ npx smartui exec [python test command]
92
+ ```
93
+ This will create new build and upload snapshot to Smart UI Project.
94
+
95
+ Executing above test
96
+
97
+ ```sh-session
98
+ $ npx smartui exec python test.py
99
+ ✔ Authenticated with SmartUI
100
+ → using project token '******#ihcjks'
101
+ ✔ SmartUI started
102
+ → listening on port 8080
103
+ ✔ Fetched git information
104
+ → branch: main, commit: 7e336e6, author: Sushobhit Dua
105
+ ✔ SmartUI build created
106
+ → build id: ee2cb6c5-9541-494a-9c75-a74629396b80
107
+ ✔ Execution of 'python3 test.py' completed; exited with code 0
108
+ → INFO:@lambdatest/python-selenium-driver:Snapshot captured name
109
+ ✔ Finalized build
110
+
111
+ ```
112
+
113
+ ## Contribute
114
+
115
+ #### Reporting bugs
116
+
117
+ Our GitHub Issue Tracker will help you log bug reports.
118
+
119
+ Tips for submitting an issue:
120
+ Keep in mind, you don't end up submitting two issues with the same information. Make sure you add a unique input in every issue that you submit. You could also provide a "+1" value in the comments.
121
+
122
+ Always provide the steps to reproduce before you submit a bug.
123
+ Provide the environment details where you received the issue i.e. Browser Name, Browser Version, Operating System, Screen Resolution and more.
124
+ Describe the situation that led to your encounter with bug.
125
+ Describe the expected output, and the actual output precisely.
126
+
127
+ #### Pull Requests
128
+
129
+ We don't want to pull breaks in case you want to customize your LambdaTest experience. Before you proceed with implementing pull requests, keep in mind the following.
130
+ Make sure you stick to coding conventions.
131
+ Once you include tests, ensure that they all pass.
132
+ Make sure to clean up your Git history, prior your submission of a pull-request. You can do so by using the interactive rebase command for committing and squashing, simultaneously with minor changes + fixes into the corresponding commits.
133
+
134
+ ## About LambdaTest
135
+
136
+ [LambdaTest](https://www.lambdatest.com/) is a cloud based selenium grid infrastructure that can help you run automated cross browser compatibility tests on 2000+ different browser and operating system environments. LambdaTest supports all programming languages and frameworks that are supported with Selenium, and have easy integrations with all popular CI/CD platforms. It's a perfect solution to bring your [selenium automation testing](https://www.lambdatest.com/selenium-automation) to cloud based infrastructure that not only helps you increase your test coverage over multiple desktop and mobile browsers, but also allows you to cut down your test execution time by running tests on parallel.
@@ -0,0 +1,10 @@
1
+ README.md
2
+ setup.py
3
+ lambdatest_playwright_driver/__init__.py
4
+ lambdatest_playwright_driver/smartui.py
5
+ lambdatest_playwright_driver/version.py
6
+ lambdatest_playwright_driver.egg-info/PKG-INFO
7
+ lambdatest_playwright_driver.egg-info/SOURCES.txt
8
+ lambdatest_playwright_driver.egg-info/dependency_links.txt
9
+ lambdatest_playwright_driver.egg-info/requires.txt
10
+ lambdatest_playwright_driver.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ playwright>=1.12
2
+ lambdatest-sdk-utils
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,31 @@
1
+ from setuptools import setup, find_packages
2
+ from os import path
3
+
4
+ cwd = path.abspath(path.dirname(__file__))
5
+ with open(path.join(cwd, 'README.md'), encoding='utf-8') as f:
6
+ long_description = f.read()
7
+
8
+ setup(
9
+ name="lambdatest-playwright-driver",
10
+ version="1.0.0",
11
+ author="LambdaTest <keys@lambdatest.com>",
12
+ description="Python Playwright SDK for visual testing with Smart UI",
13
+ long_description=long_description,
14
+ long_description_content_type="text/markdown",
15
+ url="https://github.com/LambdaTest/lambdatest-python-sdk",
16
+ keywords="lambdatest python playwright sdk visual testing",
17
+ packages=find_packages(),
18
+ license="MIT",
19
+ install_requires=[
20
+ "playwright>=1.12",
21
+ "lambdatest-sdk-utils",
22
+ ],
23
+ python_requires='>=3.7', # Playwright requires Python 3.7 or newer
24
+ classifiers=[
25
+ "Development Status :: 5 - Production/Stable",
26
+ "Programming Language :: Python :: 3",
27
+ "Natural Language :: English",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Topic :: Software Development :: Testing",
30
+ ],
31
+ )