This commit is contained in:
Lukáš Kaňka 2023-08-15 18:39:40 +02:00
commit f131cc0277
70 changed files with 638 additions and 0 deletions

3
AAA/pokus/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
<option name="processCode" value="false" />
<option name="processLiterals" value="false" />
<option name="processComments" value="false" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
AAA/pokus/.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pokus)" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pokus.iml" filepath="$PROJECT_DIR$/.idea/pokus.iml" />
</modules>
</component>
</project>

10
AAA/pokus/.idea/pokus.iml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

17
AAA/pokus/aaatest/aaa.py Normal file
View File

@ -0,0 +1,17 @@
from playwright.sync_api import Page, expect
def test_example(page: Page) -> None:
page.goto("https://www.aaaauto.cz/")
page.get_by_role("button", name="Přijmout vše").click()
page.get_by_role("button", name="Značka Vyberte značku").click()
page.get_by_text("Škoda").first.click()
page.get_by_role("button", name="Model Vyberte model").click()
page.get_by_text("Citigo").first.click()
page.get_by_role("button", name="Rok Vyberte stáří vozu").click()
page.get_by_text("Do 10 let").click()
page.get_by_role("button", name="Cena Vyberte cenu").click()
page.get_by_text("Do 200 000 Kč", exact=True).click()
page.get_by_role("button", name="Kategorie Vyberte kategorii").click()
page.locator("#hpFilterNG").get_by_text("Úsporné vozy").click()
page.get_by_role("button", name="Hledat").click()

View File

@ -0,0 +1,8 @@
from playwright.sync_api import Page, expect
def test_example(page: Page) -> None:
page.goto("https://www.google.cz/?gws_rd=ssl")
page.get_by_role("button", name="Přijmout vše").click()
page.get_by_label("Najít").click()
page.get_by_label("Najít").fill("test")

View File

@ -0,0 +1,2 @@
[pytest]
addopts = --browser chromium --headed --slowmo 1000

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/playvright.iml" filepath="$PROJECT_DIR$/.idea/playvright.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="1c2bf73c-77d3-40d2-a3de-68fd64b27bea" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/codegen_test_tutorial/aa.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/codegen_test_tutorial/aaa.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": -1
}]]></component>
<component name="ProjectId" id="2TKNMxmWNGar9iFGTYFdGKy4qKd" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/kankal/Downloads/PWjohnmediaPY/playwright-python-test-framework&quot;
}
}</component>
<component name="RunManager" selected="Python tests.Python tests for aaa.test_example">
<configuration name="Python tests for aaa.test_example" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
<module name="playvright" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/codegen_test_tutorial" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;aaa.test_example&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="Python tests for test_saucedemo.test_inventory_site" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
<module name="playvright" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/pytest" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_saucedemo.test_inventory_site&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python tests.Python tests for aaa.test_example" />
<item itemvalue="Python tests.Python tests for test_saucedemo.test_inventory_site" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1c2bf73c-77d3-40d2-a3de-68fd64b27bea" name="Changes" comment="" />
<created>1690787768083</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1690787768083</updated>
</task>
<servers />
</component>
</project>

View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="1c2bf73c-77d3-40d2-a3de-68fd64b27bea" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/codegen_test_tutorial/aa.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/codegen_test_tutorial/aaa.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 0
}</component>
<component name="ProjectId" id="2TKNMxmWNGar9iFGTYFdGKy4qKd" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/kankal/Nextcloud/GitHub/Vse Playwright_Python/PWjohnmediaPY/playvright&quot;,
&quot;project.structure.last.edited&quot;: &quot;Project&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.0&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RunManager" selected="Python tests.Python tests for test_saucedemo.test_inventory_site">
<configuration name="Python tests for aaa.test_example" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
<module name="playvright" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/codegen_test_tutorial" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;aaa.test_example&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<configuration name="Python tests for test_saucedemo.test_inventory_site" type="tests" factoryName="Autodetect" temporary="true" nameIsGenerated="true">
<module name="playvright" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/pytest" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="_new_additionalArguments" value="&quot;&quot;" />
<option name="_new_target" value="&quot;test_saucedemo.test_inventory_site&quot;" />
<option name="_new_targetType" value="&quot;PYTHON&quot;" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python tests.Python tests for test_saucedemo.test_inventory_site" />
<item itemvalue="Python tests.Python tests for aaa.test_example" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1c2bf73c-77d3-40d2-a3de-68fd64b27bea" name="Changes" comment="" />
<created>1690787768083</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1690787768083</updated>
<workItem from="1690990947705" duration="168000" />
<workItem from="1690991135379" duration="71000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
</project>

View File

@ -0,0 +1,21 @@
Video 2 nastavuji
doporučuji zde se podívat jak stopnout některy browsey https://youtu.be/IDrTacdVNRM?t=838
@pytest.mark.skip_browser("firefox")
@pytest.mark.only_browser("chrome")
pytest --tracing on --> tento pžíkaz na spuštění testu vytvoří složky kde je v zip výsledek testu
zip mohu otevřít zde a podívat se na výsledek testu https://trace.playwright.dev/
další možnosti jak využít trace.zip https://youtu.be/IDrTacdVNRM?t=1148
na inportovaném pytest.ini mužu nastavit default URL a další parametry
Video 3 codegen a Inspektor
v codegen vygeneruji v mém případě zatím code v pytest
https://playwright.dev/python/docs/codegen#recording-a-test
https://playwright.dev/python/docs/debug
video jakým vše možným způsobem se dá použít playwright codegen je zde: https://youtu.be/IRTeqUXkPbA
třeba je mémožné ho použít na nacvakání jako na iPhone, nebo daným rozlišení stránky
velikost textu se zobrazí v nastavení parametrů přímo v testu
navíc můžeme importovat tmavé schéma, geolokační data (od kud přistupuji na net), vše je v dokumentaci

View File

@ -0,0 +1,12 @@
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
await page.goto("https://lukan.cz")
print(await page.title())
await browser.close()
asyncio.run(main())

View File

@ -0,0 +1,28 @@
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
page.goto("https://www.aaaauto.cz/")
page.get_by_role("button", name="Přijmout vše").click()
page.get_by_role("button", name="Značka Vyberte značku").click()
page.get_by_text("Škoda (2793)").first.click()
page.get_by_role("button", name="Model Vyberte model").click()
page.get_by_text("Citigo(40)").click()
page.get_by_role("button", name="Rok Vyberte stáří vozu").click()
page.get_by_text("Do 10 let").click()
page.get_by_role("button", name="Cena Vyberte cenu").click()
page.get_by_text("Do 200 000 Kč", exact=True).click()
page.get_by_role("button", name="Kategorie Vyberte kategorii").click()
page.locator("#hpFilterNG").get_by_text("Úsporné vozy").click()
page.get_by_role("button", name="Hledat").click()
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)

View File

@ -0,0 +1,17 @@
from playwright.sync_api import Page, expect
def test_example(page: Page) -> None:
page.goto("https://www.aaaauto.cz/")
page.get_by_role("button", name="Přijmout vše").click()
page.get_by_role("button", name="Značka Vyberte značku").click()
page.get_by_text("Škoda").first.click()
page.get_by_role("button", name="Model Vyberte model").click()
page.get_by_text("Citigo").click()
page.get_by_role("button", name="Rok Vyberte stáří vozu").click()
page.get_by_text("Do 10 let").click()
page.get_by_role("button", name="Cena Vyberte cenu").click()
page.get_by_text("Do 200 000 Kč", exact=True).click()
page.get_by_role("button", name="Kategorie Vyberte kategorii").click()
page.locator("#hpFilterNG").get_by_text("Úsporné vozy").click()
page.get_by_role("button", name="Hledat").click()

View File

@ -0,0 +1,2 @@
[pytest]
addopts = --browser chromium --headed --slowmo 1000

View File

@ -0,0 +1,17 @@
from playwright.sync_api import Page, expect
def test_example(page: Page) -> None:
page.goto("https://www.saucedemo.com/")
page.locator("[data-test=\"username\"]").click()
page.locator("[data-test=\"username\"]").fill("standard_user")
page.locator("[data-test=\"password\"]").click()
page.locator("[data-test=\"password\"]").fill("secret_sauce")
page.locator("[data-test=\"login-button\"]").click()
# v codegen vygeneruji v mém případě zatím code v pytest
# https://playwright.dev/python/docs/codegen#recording-a-test
# video jakým vše možným způsobem se dá použít playwright codegen je zde: https://youtu.be/IRTeqUXkPbA
# třeba jeémožné ho použít na nacvakání jako na iPhone, nebo daným rozlišení stránky
# velikost textu se zobrazí v nastavení parametrů přímo v testu

View File

@ -0,0 +1,17 @@
import pytest
from playwright.sync_api import Page, expect
@pytest.fixture(scope="session")
def browser_context_args(browser_context_args, playwright):
return {**playwright.devices["iPhone 13"]}
def test_example(page: Page) -> None:
page.goto("https://www.saucedemo.com/")
page.locator("[data-test=\"username\"]").click()
page.locator("[data-test=\"username\"]").fill("standard_user")
page.locator("[data-test=\"password\"]").click()
page.locator("[data-test=\"password\"]").fill("secret_sauce")
page.locator("[data-test=\"login-button\"]").click()

View File

@ -0,0 +1,20 @@
from playwright.sync_api import Page, expect
@pytest.fixture(scope="session")
def browser_context_args(browser_context_args, playwright):
return {"viewport": {"width":763,"height":481}}
def test_example(page: Page) -> None:
page.goto("https://www.saucedemo.com/")
page.locator("[data-test=\"username\"]").click()
page.locator("[data-test=\"username\"]").fill("standard_user")
page.locator("[data-test=\"password\"]").click()
page.locator("[data-test=\"password\"]").fill("secret_user")
page.locator("[data-test=\"login-button\"]").click()
page.get_by_text("Epic sadface: Username and password do not match any user in this serviceLoginAc").click()
page.locator("[data-test=\"password\"]").click()
page.locator("[data-test=\"password\"]").click()
page.locator("[data-test=\"password\"]").fill("secret_sauce")
page.locator("[data-test=\"login-button\"]").click()

View File

@ -0,0 +1,2 @@
[pytest]
addopts = --base-url https://www.saucedemo.com/ --browser chromium --headed --slowmo 1000

View File

@ -0,0 +1,22 @@
from playwright.sync_api import Page
import pytest
#doporučuji zde se podívat jak stopnout některy browsey https://youtu.be/IDrTacdVNRM?t=838
# @pytest.mark.skip_browser("firefox")
# @pytest.mark.only_browser("chrome")
def test_title(page: Page):
page.goto("/")
assert page.title() == "Swag Labs"
def test_inventory_site(page: Page):
page.goto("/inventory.html")
assert page.inner_text('h3') == "Epic sadface: You can only access '/inventory.html' when you are logged in."
# pytest --tracing on --> tento pžíkaz na spuštění testu vytvoří složky kde je v zip výsledek testu
# zip mohu otevřít zde a podívat se na výsledek testu https://trace.playwright.dev/
# další možnosti jak využít trace.zip https://youtu.be/IDrTacdVNRM?t=1148
# na inportovaném pytest.ini mužu nastavit default URL a další parametry

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

View File

@ -0,0 +1,7 @@
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless= False)
page = browser.new_page()
page.goto("https://lukan.cz")
page.screenshot(path="screenshot/lukan.png")
browser.close()

3
PWlkPY/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

10
PWlkPY/.idea/PWlkPY.iml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
PWlkPY/.idea/misc.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (PWlkPY) (2)" project-jdk-type="Python SDK" />
</project>

8
PWlkPY/.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/PWlkPY.iml" filepath="$PROJECT_DIR$/.idea/PWlkPY.iml" />
</modules>
</component>
</project>

6
PWlkPY/.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

2
PWlkPY/pokus/pytest.ini Normal file
View File

@ -0,0 +1,2 @@
[pytest]
addopts = --base-url https://lukaskanka.cz/ --browser chromium --headed --slowmo 1000

14
PWlkPY/pokus/test_menu.py Normal file
View File

@ -0,0 +1,14 @@
from playwright.sync_api import Page
import pytest
def test_tlacitek_menu(page: Page):
page.goto("/")
# tlačítko články
page.locator('//*[@id="menu"]/ul/li[1]/strong/a').click()
# tlačítko Hlavní stránka
page.locator('//*[@id="menu"]/ul/li[1]/strong/a').click()
# tlačítko O mně
page.locator('//*[@id="menu"]/ul/li[2]/strong/a').click()
# tlačítko Hlavní stránka
page.locator('//*[@id="menu"]/ul/li[1]/strong/a').click()

3
PWneemoPY/playwright/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
<option name="processCode" value="false" />
<option name="processLiterals" value="false" />
<option name="processComments" value="false" />
</inspection_tool>
</profile>
</component>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/playwright.iml" filepath="$PROJECT_DIR$/.idea/playwright.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,13 @@
from playwright.sync_api import Page
import pytest
def test_example(page: Page) -> None:
page.goto("https://www.google.com/")
page.get_by_role("button", name="Přijmout vše").click()
page.get_by_label("Najít").click()
page.get_by_label("Najít").fill("playwright")
page.get_by_label("Hledat Googlem").first.click()
page.get_by_role("link", name="Playwright: Fast and reliable end-to-end testing for modern ... playwright.dev https://playwright.dev").click()

View File

@ -0,0 +1,2 @@
[pytest]
addopts = --browser chromium --headed --slowmo 1000 --tracing on

3
PWpokusPY/Pokus1/.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (Pokus1)" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Pokus1.iml" filepath="$PROJECT_DIR$/.idea/Pokus1.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,20 @@
import re
from playwright.sync_api import Page, expect
def test_homepage_lukan_cz_accept_cookies(page: Page):
page.goto("https://lukan.cz/")
get_accept = page.get_by_text("Accept")
get_accept.click()
#vypíše titulek stánky
print( page.title())
#Vytvoříme foto stránky
page.screenshot(path="screenshot/lukan.png")
def test_homepage_lukan_cz_decline_cookies(page: Page):
page.goto("https://lukan.cz/")
get_decline = page.get_by_text("Decline")
get_decline.click()

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB