Skip to content

How to mock external services? #1142

Answered by mdmintz
rdmolony asked this question in Q&A
Dec 20, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

Hello @rdmolony, SeleniumBase allows you to set a proxy server when running tests, which you can use together with the browsermobproxy. There are two ways to set the proxy.
1: From the command-line with pytest:
--proxy="server:port"
2: By spinning up a new driver from within a test:
driver2 = self.get_new_driver(proxy="server:port")
If authentication is required, you can expand that format to user:pass@server:port.
If using option 2, all self.* methods will automatically start using the new driver that you have spun up. Assuming that you have correctly set up your proxy server, the web browser will use that while tests are running.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@rdmolony
Comment options

@mdmintz
Comment options

@rdmolony
Comment options

Answer selected by mdmintz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants