1 year ago
#132555
Gus
AWS Device Farm with Selenium Wire Remote WebDriver
In my project, to be able to access a testing environment website I need to send a header request, otherwise I get a 404 error. I'm running Selenium-wire using Jenkins on a server and running the browser on AWS Device Farm. The thing is, some sites don't need the header and I can access normally, and for those the next config are working fine:
if browser_name == "chrome":
options = webdriver.ChromeOptions()
options.add_argument("--ignore-certificate-errors")
options.add_argument("--no-sandbox")
devicefarm_client = boto3.client("devicefarm", region_name="us-west-2")
testgrid_url_response = devicefarm_client.create_test_grid_url(
projectArn="arn:aws:devicefarm:us-west-2:111122223333:testgrid-project:123e4567-e89b-12d3-a456-426655440000", # < exemple project's Amazon Resource Name (ARN)
expiresInSeconds=300,
)
desired_capabilities = DesiredCapabilities.CHROME
desired_capabilities["platform"] = "windows"
driver = webdriver.Remote(
testgrid_url_response["url"], desired_capabilities, options=options,
seleniumwire_options={'auto_config': False, 'addr': '127.0.0.1'}
)
driver.set_window_size(1920, 1080)
driver.implicitly_wait(30)
driver.get("...")
For the site where I need to use the header I first start just adding the 'interceptor' function, and then I tried many other things:
elif browser_name == "chrome_1":
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument('--proxy-server="IP-of-the-machine-running-Jenkins":8087')
devicefarm_client = boto3.client("devicefarm", region_name="us-west-2")
testgrid_url_response = devicefarm_client.create_test_grid_url(
projectArn="arn:aws:devicefarm:us-west-2:111122223333:testgrid-project:123e4567-e89b-12d3-a456-426655440000", # < exemple project's Amazon Resource Name (ARN)
expiresInSeconds=300,
)
desired_capabilities = DesiredCapabilities.CHROME
desired_capabilities["platform"] = "windows"
driver = webdriver.Remote(
testgrid_url_response["url"], desired_capabilities, options=chrome_options,
seleniumwire_options={'auto_config': False, 'addr': '127.0.0.1', 'port': 8087} # < Here I've tried 0.0.0.0, IP of Jenkins machine, etc...
)
driver.set_window_size(1920, 1080)
driver.implicitly_wait(30)
def interceptor(request):
request.headers['x-abc-abcdef'] = 'the-header-value'
driver.request_interceptor = interceptor
driver.get("...")
Plus, locally the 'interceptor' function with header work just fine in granting me access.
If anybody could throw some light here I'd be immensely grateful!
Thanks!
amazon-web-services
jenkins
aws-device-farm
seleniumwire
0 Answers
Your Answer