You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private WebDriver driver;
private BrowserMobProxy proxyServer;
@BeforeMethod
public void setUp() throws UnknownHostException {
// Set up the BrowserMob proxy in order to block the calls to Google Ads that some times block the browser
proxyServer = new BrowserMobProxyServer();
// This are the patterns of our sites, in real life there are more...
List<String> allowUrlPatterns = new ArrayList<String>();
allowUrlPatterns.add("https?://.*(newhomesource.com)+.*");
// All the URLs that are not from our sites are blocked and a status code of 403 is returned
proxyServer.whitelistRequests(allowUrlPatterns, 404);
proxyServer.start(9091, InetAddress.getLocalHost());
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
// get the Selenium proxy object
Proxy proxy = ClientUtil.createSeleniumProxy(proxyServer);
capabilities.setCapability(CapabilityType.PROXY, proxy);
driver = new FirefoxDriver(capabilities);
}
@Test
public void test() {
driver.get("http://www.newhomesource.com");
// Do a search
driver.findElement(By.id("SearchText")).sendKeys("Austin, tx area");
driver.findElement(By.id("HomeSearchBtn")).click();
}
@AfterTest
public void cleamUp(){
driver.quit();
proxyServer.stop();
}
Thanks in advance for all your work, BrowserMob proxy is a great tool, and the whitelist and blacklist an important feature and I have to say that I am glad the development of browsermob proxy continues after a time without releases. Please let me know if you need more information.
Thanks,
Jose
The text was updated successfully, but these errors were encountered:
This issue was fixed by PR #261 and PR #273, which are now in master. There is one outstanding issue I want to get fixed before beta-2 is released, but it will most likely be released to Central within the next few days.
The Urls that match the blacklist or the Urls that do not match the whitelist do not return, the browser timeouts waiting for an answer of those Urls.
I am using Maven, Windows 7 64bits, Java 1.8, TestNG, Selenium 2.46 and browsermob-core-littleproxy 2.1.0-beta-1.
I prepared a sample maven project with the case to reproduce this issue, but it seems that I can't upload it, so here you have my TestNG test case:
package test.whiteList;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import net.lightbody.bmp.BrowserMobProxy;
import net.lightbody.bmp.BrowserMobProxyServer;
import net.lightbody.bmp.client.ClientUtil;
import org.openqa.selenium.By;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class WhiteListTest {
}
And this is the content of my pom.xml
4.0.0
test
test
0.0.1-SNAPSHOT
WhiteListExample
<suite.xml.file>testsuite.xml</suite.xml.file>
org.seleniumhq.selenium
selenium-java
2.46.0
org.testng
testng
6.8
net.lightbody.bmp
browsermob-core-littleproxy
2.1.0-beta-1
org.apache.commons
commons-lang3
3.1
com.google.guava
guava
18.0
com.googlecode.json-simple
json-simple
1.1.1
org.apache.commons
commons-lang3
3.1
${project.basedir}/${output_folder}
${project.build.directory}/classes
org.apache.maven.plugins
maven-surefire-plugin
2.18
false
1
true
${suite.xml.file}
org.apache.maven.plugins
maven-resources-plugin
2.6
UTF-8
src/main/resources
true
Thanks in advance for all your work, BrowserMob proxy is a great tool, and the whitelist and blacklist an important feature and I have to say that I am glad the development of browsermob proxy continues after a time without releases. Please let me know if you need more information.
Thanks,
Jose
The text was updated successfully, but these errors were encountered: