URL Blacklisting

130 views
Skip to first unread message

Mandi B.

unread,
Aug 31, 2018, 9:14:35 AM8/31/18
to robotframework-users
Hi all, 

I have been reading up setting up a proxy with browsermob in order to blacklist some URLs to speed up test execution but I have failed in setting it up. 
Does anyone have a snippet that can share our point me in the right direction? I don't know much about proxies and all this is new to me ...

Thanks

Mandi B.

unread,
Aug 31, 2018, 11:50:21 AM8/31/18
to robotframe...@googlegroups.com
This is my current progress but whatever I write as regexp in ${BrowserMob_Proxy}=    Blacklist    (https://.*\\.google.com/.*    404), Google is never blocked and always opens 

*** Keywords ***
Start Browser
    [Documentation]    Start chrome browser
    Set Selenium Implicit Wait    10

    ## Init BrowserMob Proxy
    ${BMPATH}    Join Path    ${EXECDIR}    browsermob-proxy-2.1.4    bin    browsermob-proxy.bat
    Start Local Server    ${BMPATH}

    ## Create dedicated proxy on BrowserMob Proxy
    &{host}    Create Dictionary    address=127.0.0.1    port=7070
    ${BrowserMob_Proxy}=    Create Proxy    ${host}

    #Blacklist URLS
    ${BrowserMob_Proxy}=    Blacklist    (https://.*\\.google.com/.*    404)

    ## Configure Webdriver to use BrowserMob Proxy
    ${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${options}    add_argument    --proxy\=127.0.0.1:7070

    Create WebDriver    Chrome    chrome_options=${options}
    Go to    https://www.google.com

Anyone can help? 

Bryan Oakley

unread,
Aug 31, 2018, 12:13:24 PM8/31/18
to stefan.m...@gmail.com, robotframework-users
Most likely it's because you're calling Blacklist with two arguments:
  1. (https://.*\\.google.com/.*
  2. 404)
I doubt that's what the keyword is expecting. Though, I'm surprised it isn't throwing some sort of error since the first is not a proper regex, and the last is not a proper response code. 

On Fri, Aug 31, 2018 at 10:50 AM Mandi B. <stefan.m...@gmail.com> wrote:
This is my current progress but whatever I write as regexp in line 13, google is never blocked and always opens 

*** Keywords ***
Start Browser
    [Documentation]    Start chrome browser
    Set Selenium Implicit Wait    10

    ## Init BrowserMob Proxy
    ${BMPATH}    Join Path    ${EXECDIR}    browsermob-proxy-2.1.4    bin    browsermob-proxy.bat
    Start Local Server    ${BMPATH}

    ## Create dedicated proxy on BrowserMob Proxy
    &{host}    Create Dictionary    address=127.0.0.1    port=7070
    ${BrowserMob_Proxy}=    Create Proxy    ${host}

    #Blacklist URLS
    ${BrowserMob_Proxy}=    Blacklist    (https://.*\\.google.com/.*    404)

    ## Configure Webdriver to use BrowserMob Proxy
    ${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${options}    add_argument    --proxy\=127.0.0.1:7070

    Create WebDriver    Chrome    chrome_options=${options}
    Go to    https://www.google.com

Anyone can help? 

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages