Beispiel #1
0
    async def test_frame_events(self, ee_helper):
        await self.reset_and_goto_empty()
        attachedFrames = []
        ee_helper.addEventListener(self.page, Events.Page.FrameAttached,
                                   lambda f: attachedFrames.append(f))
        await TestUtil.attachFrame(self.page, "frame1",
                                   self.full_test_url("frame.html"))
        with should(attachedFrames):
            should.have.length.of(1)
            should.have.index.at(0).that.should.have.property("url").equal.to(
                self.full_test_url("frame.html"))

        navigatedFrames = []
        ee_helper.addEventListener(self.page, Events.Page.FrameNavigated,
                                   lambda f: navigatedFrames.append(f))
        await TestUtil.navigateFrame(self.page, "frame1",
                                     self.full_test_url("empty.html"))
        with should(navigatedFrames):
            should.have.length.of(1)
            should.have.index.at(0).that.should.have.property("url").equal.to(
                self.full_test_url("empty.html"))

        detachedFrames = []
        ee_helper.addEventListener(self.page, Events.Page.FrameDetached,
                                   lambda f: detachedFrames.append(f))
        await TestUtil.detachFrame(self.page, "frame1")
        len(detachedFrames) | should.be.equal.to(1)
        detachedFrames[0].isDetached() | should.be.true
Beispiel #2
0
 async def test_reconnect(self, one_off_chrome: Chrome):
     browserWSEndpoint = one_off_chrome.wsEndpoint
     await one_off_chrome.disconnect()
     browser2 = await connect(browserWSEndpoint=browserWSEndpoint)
     page = await browser2.newPage()
     with should(await page.evaluate("() => 7 * 8")):
         should.be.a(int).that.should.be.equal.to(56)
     await browser2.disconnect()
Beispiel #3
0
def we_get_an_echo_response(context, method):
    context.resp.json["method"] | should.be.equal.to(method.upper())
    context.resp.json["path"] | should.be.equal.to("/sample")
    with should(context.resp.json):
        should.be.a(dict)
        should.have.key("headers").to.be.a(dict)
        should.have.key("params").to.be.a(dict)
        should.have.key("payload").to.be.a(dict)
        should.have.key("query").to.be.a(str)
Beispiel #4
0
 async def test_enable_disable_domain(self):
     client = await self.page.target.createSession()
     await client.send("Runtime.enable")
     await client.send("Runtime.disable")
     res = await client.send("Runtime.evaluate", {
         "expression": "1 + 3",
         "returnByValue": True
     })
     with should(res):
         should.have.key("result").that.should.have.key("value").equal.to(4)
     await client.detach()
Beispiel #5
0
 async def test_click_link(self, ee_helper):
     await self.goto_empty()
     results = []
     ee_helper.addEventListener(self.page, Events.Page.FrameNavigated,
                                lambda x: results.append(True))
     await self.page.setContent(
         '<a href="{}">empty.html</a>'.format("f{self.url}empty.html"))
     await self.page.click("a")
     await asyncio.sleep(1)
     with should(results):
         should.have.length.of(1)
         should.have.index.at(0).that.should.be.true
Beispiel #6
0
    async def test_detach(self):
        client = await self.page.target.createSession()
        await client.send("Runtime.enable")
        evalResponse = await client.send("Runtime.evaluate", {
            "expression": "1 + 2",
            "returnByValue": True
        })
        with should(evalResponse):
            should.have.key("result").that.should.have.key("value").equal.to(3)

        await client.detach()
        with pytest.raises(NetworkError):
            await client.send("Runtime.evaluate", {
                "expression": "1 + 3",
                "returnByValue": True
            })
Beispiel #7
0
def the_response_tags_include(context, field, name, value):
    with should(context.resp.json):
        should.have.key(field).to.be.a(dict)
    with should(context.resp.json.get(field)):
        should.have.key(name).that.should.be.equal.to(value)
def the_user_gets_back_a_token(context):
    with should(context.resp.json):
        should.be.a(dict)
        should.have.key("token").to.be.a(str)