In this example, we are providing instructions for editing the host file within a VM, so that when the driver tries to access "www.google.com" it will instead be re-directed to "www.saucelabs.com" (i.e IP 220.127.116.11).
This host file edit will only impact the Sauce Labs VM provisioned for this test, thus this will not impact the host file within your local system. Also, in order to accomplish this, you should be very comfortable with writing and troubleshooting shell scripts.
Here are the steps:
- Write a script that indicates the IP address that you want to re-direct the desired URL to. For example: >Mac/Linux or >Windows
- Upload the script to your temporary sauce storage or somewhere where you can access it publicly on the internet. For example, I used my GitHub repository.
- Write the test and use the pre-run desired capability which will load your script as a host file in the VM before the test starts. For example: EditHostFileTest
Can I do this over a Sauce Connect Secured Tunnel?
Yes, you should be able to accomplish this when using Sauce Connect. The only difference is that you will have to edit the host file on the computer from where you are running Sauce Connect.
For this case, instead of writing a script and pointing the test to use such script, you will have to edit the host file on the computer from where you are running Sauce Connect. This will work because Sauce Connect always uses the host file from the computer that is running, instead of using the host file currently living in the VM.
As you can imagine, for this case you don't need to use the pre-run desired capability to point the test to your host file script. Instead, you will only have to:
- Edit the host file in the computer from where you are running Sauce Connect.
- Start Sauce Connect.
- Run your test as you usually do.
- Visit the following repository for reference: https://github.com/albedithdiaz/sauceSupport