Esempio n. 1
0
    def test_admin_login(page: Page):
        """
        登录后台
        """
        # Click [placeholder="请输入用户名"]
        page.click("[placeholder=\"请输入用户名\"]")
        # Fill [placeholder="请输入用户名"]
        page.fill("[placeholder=\"请输入用户名\"]", "admin")
        # Fill [placeholder="请输入登录密码"]
        page.fill("[placeholder=\"请输入登录密码\"]", "shopxo")
        # Click button:has-text("登录")
        page.click("button:has-text(\"登录\")")
        # Go to http://localhost/shopxo/admin.php?s=/index/index.html
        page.goto("http://localhost/shopxo/admin.php?s=/index/index.html")

        assert page.url == 'http://localhost/shopxo/admin.php?s=/index/index.html'
Esempio n. 2
0
    def test_admin_click_menu(page: Page):
        """
        登录后台
        """

        # Click text=系统设置
        page.click("text=系统设置")
        # Click text=站点配置
        page.click("text=站点配置")
        # Click text=权限控制
        page.click("text=权限控制")
        # Click text=用户管理
        page.click("text=用户管理")
        # Click text=商品管理
        page.click("text=商品管理")

        assert 1 == 1
Esempio n. 3
0
async def test_should_accept_single_file(page: Page, server):
    await page.setContent('<input type=file oninput="javascript:console.timeStamp()">')
    file_chooser = (
        await asyncio.gather(page.waitForEvent("filechooser"), page.click("input"),)
    )[0]
    assert file_chooser.page == page
    assert file_chooser.element
    await file_chooser.setFiles(FILE_TO_UPLOAD)
    assert await page.evalOnSelector("input", "input => input.files.length") == 1
    assert (
        await page.evalOnSelector("input", "input => input.files[0].name")
        == "file-to-upload.txt"
    )
Esempio n. 4
0
async def test_should_report_downloads_with_acceptDownloads_false(page: Page, server):
    await page.setContent(
        f'<a href="{server.PREFIX}/downloadWithFilename">download</a>'
    )
    download = (await asyncio.gather(page.waitForEvent("download"), page.click("a")))[0]
    assert download.url == f"{server.PREFIX}/downloadWithFilename"
    assert download.suggestedFilename == "file.txt"
    error: Optional[Error] = None
    try:
        await download.path()
    except Error as exc:
        error = exc
    assert "acceptDownloads" in await download.failure()
    assert error
    assert "acceptDownloads: true" in error.message