Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] how to get file by route request Intercept when form file upload #16579

Closed
nappinglady opened this issue Aug 16, 2022 · 4 comments
Closed

Comments

@nappinglady
Copy link

how to get file by route request Intercept when form file upload?
cant frind in request method

@aslushnikov
Copy link
Collaborator

@nappinglady I don't think I follow the question. What exactly do you want to do?

@nappinglady
Copy link
Author

nappinglady commented Aug 17, 2022

[>] @nappinglady I don't think I follow the question. What exactly do you want to do?

@aslushnikov thanks for reply
for example i have a upload file form
image

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height">
    <title>test playwright intercept file</title>
    <style>::-webkit-scrollbar{display:none;}html,body{overflow:hidden;height:100%;margin:0;}</style>
</head>
<body>
  <form enctype="multipart/form-data" action="http://localhost:8004/Upload/Upload"  method="post">
    <input type="file" name="file"/>
    <input type="text" name="name"/>
    <input type="submit" value="上传"/>
  </form>
</body>
</html>

then i want to get file by intercept like this

test.describe('lpp', async () => {
    await test('lpp',async ({ page }) => {
       await page.goto("file:///E:/study/antv/uploadfile.html");
       page.route(/.*localhost.*/g,async(route,request)=>{
            console.log(request)
            console.log(route)
            console.log(request.postData());     
            console.log(await request.headersArray());     
            console.log(request.postDataBuffer());     
           await route.continue();
           console.log(await (await request.response())?.json());
       })
       await page.waitForTimeout(100000);
    });
});

image


i cant get file by request or route

@nappinglady
Copy link
Author

@nappinglady I don't think I follow the question. What exactly do you want to do?
@aslushnikov or how to get file and redirect my new request url , and New URL has different protocol with original
https://playwright.dev/docs/next/api/class-route#route-continue

@aslushnikov
Copy link
Collaborator

Ah! This is a dupe of #6479

Merging this one; please upvote #6479 to receive updates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants