Skip to content

Add option to enable connecting to multiple authenticated proxies during tests #1832

Closed
@mdmintz

Description

@mdmintz

Add option to enable connecting to multiple authenticated proxies during tests

Currently, proxy.zip and proxy_ext_dir are hardcoded so that tests can connect to a proxy and reuse the same config, but that can be limiting if people want to connect to multiple proxies for multi-threaded tests. I'm planning on adding the following options to allow for flexible naming based on number increments:

  • --multi-proxy (Command-line option for pytest)
  • multi_proxy=True (SB manager, Driver manager, browser_launcher direct calls)

This would result in creating proxy_1.zip, proxy_2.zip, etc. and proxy_ext_dir_1, proxy_ext_dir_2, etc. for each test so that different authenticated proxies can be used.

Eg. (Via parameterized tests):

from parameterized import parameterized
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)

class SearchTests(BaseCase):
    @parameterized.expand(
        [
            ["user1:pass1@server1:port1"],
            ["user2:pass2@server2:port2"],
            ["user3:pass3@server3:port3"],
        ]
    )
    def test_parameterized_proxy(self, proxy_string):
        self.get_new_driver(proxy=proxy_string)
        # ...

And run that with: pytest -n=3 --multi-proxy

Enabling this via an option (rather than having this always enabled) is important so that the downloaded_files folder (where proxy config files are stored) isn't getting polluted with multiple identical files when the same proxy configuration is being used for all tests on purpose.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions