如何使用Dart的webdriver跟踪网络流量

时间:2015-07-30 07:16:25

标签: selenium-webdriver proxy dart webdriver

API文档过于简单,我不知道如何使用dart的webdriver跟踪网络流量,在selenuium中可能会使用以下内容:

   Proxy proxy = new Proxy(); 
    // The URL here is the URL that the browsermob proxy is using   
     proxy.setHttpProxy("localhost:9100");     
     DesiredCapabilities capabilities = DesiredCapabilities.firefox();
     capabilities.setCapability(CapabilityType.PROXY, proxy);   
     WebDriver driver = new FirefoxDriver(capabilities);

但我是dart的新手,不知道用于设置代理的库以及如何为dart webdriver设置代理。可以给我一个简单的例子吗?

1 个答案:

答案 0 :(得分:1)

您可以像

一样配置驱动程序
WebDriver driver = await createDriver(
  uri: Uri.parse('http://localhost:4444/wd/hub/'),
  desired: {'browserName': 'firefox', 
    'proxy': {'proxyType': 'direct', 'httpProxy': 'localhost:9100'}});

我还没有使用代理,也不知道direct在这里是否有意义,但需要一些价值。您可以在https://code.google.com/p/selenium/wiki/DesiredCapabilities#Proxy_JSON_Object

找到可能的值