Selenium获取.har文件 [英] Selenium get .har file

查看:1084
本文介绍了Selenium获取.har文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两页申请:

/ login

/个人资料

我想要获得.har文件页面 / profile

当我转到 / login 页面时,使用key = connect.sid和value =example value创建cookie。此cookie尚未激活。
我添加了活动connect.sid的cookie。

I have a two page application:
/login
/profile
I want to get .har file page /profile.
When i go to the page /login, the cookie is created with a key=connect.sid and value = "example value". This cookie is not yet active. I added the cookies with active connect.sid.

WebDriver webDriver = getDriver();
webDriver.get(LOGIN_PAGE);
webDriver.manage().addCookie(connectsSId);

它不起作用,因为在加载页面之后,/ login创建了一个新的cookie。
我也试过这段代码:

it does not work because after the load page, /login crated a new cookies. i also tried this code:

WebDriver webDriver = getDriver();
webDriver.get(PROFILE_PAGE);
webDriver.manage().deleteAllCookies();
webDriver.manage().addCookie(connectsSId);

这不起作用。添加了cookie,但似乎为时已晚。

and this does not work. cookies were added but it seems too late.

 WebDriver webDriver = getDriver();
 LoginPage loginPage = new LoginPage(getDriver());
 LandingPage landingPage = loginPage.login();
 landingPage.openProfilePage();

此代码为页面 / login 创建了一个.har文件。

由于某种原因,文件仅在第一次调用页面后创建。我无法解决这个问题。

This code created a .har file for the page /login.
for some reason, the file is created only after the first call to the page. I can not solve this problem.

推荐答案

您可以使用browsermob代理捕获所有请求和响应数据
< a href =https://github.com/lightbody/browsermob-proxy =nofollow>见这里

You can use browsermob proxy to capture all the request and response data See here

这篇关于Selenium获取.har文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆