I get empty Har file with this library.
I work with browsermob-proxy 0.8.0; robotframework 3.2.2; robotframework-browsermobproxylibrary 0.1.3; robotframework-selenium2library 3.0.0; selenium 3.141.0 and python 3.8.5 and chrome 88.0.4324.182 (64bit)
It can open proxy server, open brower and open right page, however, it will get har file with empty entries.
Here is empty Har
{"log": {"version": "1.2", "creator": {"name": "BrowserMob Proxy", "version": "2.1.4", "comment": ""}, "pages": [{"id": "google", "startedDateTime": "2021-02-28T22:00:02.929+08:00", "title": "google", "pageTimings": {"comment": ""}, "comment": ""}], "entries": [], "comment": ""}}
Here is my code
*** Settings ***
Metadata VERSION 0.1
Library Selenium2Library
Library Collections
Library OperatingSystem
Library BrowserMobProxyLibrary
Suite Setup Start Browser
Suite Teardown Close Browsers
*** Variables ***
${PAGE_URL} https://www.baidu.com
${BROWSER} Chrome
*** Keywords ***
Start Browser
[Documentation] Start firefox browser
Set Selenium Implicit Wait 10
## Init BrowserMob Proxy
Start Local Server /home/wzl/ISCAS/robot/WorkSpace/Har/browsermob-proxy-2.1.4/bin/browsermob-proxy
## Create dedicated proxy on BrowserMob Proxy
${BrowserMob_Proxy}= Create Proxy
## Configure Webdriver to use BrowserMob Proxy
${options} = Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
Call Method ${options} add_argument --proxy\=${BrowserMob_Proxy}
create webdriver ${BROWSER} chrome_options=${options}
Close Browsers
Close All Browsers
Stop Local Server
*** Test Cases ***
Check something
[Documentation] Check the page title
New Har google
Go to ${PAGE_URL}
Input text id=kw robot framework
click button id=su
sleep 3s
${har}= Get Har As JSON
create file ${EXECDIR}${/}file.har ${har}
log to console Browsermob Proxy HAR file saved as ${EXECDIR}${/}file.har
Log har is ${har}
And I use BrowserMob Proxy directly with python, It can get right har file.
Code is here:
from browsermobproxy import Server
from selenium import webdriver
import time
import pprint
class ProxyManager:
__BMP = "/home/wzl/ISCAS/robot/WorkSpace/Har/browsermob-proxy-2.1.4/bin/browsermob-proxy"
def __init__(self):
self.__server = Server(ProxyManager.__BMP)
self.__client = None
def start_server(self):
self.__server.start();
return self.__server
def start_client(self):
self.__client = self.__server.create_proxy(params={"trustAllServers": "true"})
return self.__client
@property
def client(self):
return self.__client
@property
def server(self):
return self.__server
if "__main__" == __name__:
proxy = ProxyManager()
server = proxy.start_server()
client = proxy.start_client()
client.new_har("baidu.com")
print(client.proxy)
options = webdriver.ChromeOptions()
options.add_argument("--proxy-server={}".format(client.proxy))
driver = webdriver.Chrome(chrome_options = options)
driver.get("https://www.baidu.com")
time.sleep(3)
pprint.pprint(client.har)
server.stop()
I had tried some other way to use robotframework-BrowserMobProxyLibrary.
just like No log entries found for BrowserMobProxy With Robot Framework
and How to run BrowserMob Proxy with RobotFramework and Capture HAR files
, they all get empty entires.
Or with python2.7.18· and browsermob-proxy 0.8.0; robotframework 2.8.2; robotframework-browsermobproxylibrary 0.1.3; robotframework-selenium2library 1.7.0; selenium 2.53.6 andchrome 88.0.4324.182 (64bit)`
With windows10 and Ubuntu 20.04.2
They all show the situation same with above empty entires har file.
I do not know what's wrong happened。
Thanks in advance!
I get empty Har file with this library.
I work with
browsermob-proxy 0.8.0; robotframework 3.2.2; robotframework-browsermobproxylibrary 0.1.3; robotframework-selenium2library 3.0.0; selenium 3.141.0andpython 3.8.5andchrome 88.0.4324.182 (64bit)It can open proxy server, open brower and open right page, however, it will get har file with empty entries.
Here is empty Har
Here is my code
And I use BrowserMob Proxy directly with python, It can get right har file.
Code is here:
I had tried some other way to use robotframework-BrowserMobProxyLibrary.
just like No log entries found for BrowserMobProxy With Robot Framework
and How to run BrowserMob Proxy with RobotFramework and Capture HAR files
, they all get empty entires.
Or with
python2.7.18· andbrowsermob-proxy 0.8.0; robotframework 2.8.2; robotframework-browsermobproxylibrary 0.1.3; robotframework-selenium2library 1.7.0; selenium 2.53.6andchrome 88.0.4324.182 (64bit)`With windows10 and Ubuntu 20.04.2
They all show the situation same with above empty entires har file.
I do not know what's wrong happened。
Thanks in advance!