TestProject Forum
Powered by leading experts in the test automation community

Allow CORS for the test Recorder and running tests

Hello,
I’ve been trying to create some tests using the test recorder for one of our websites. I’d like to create the test on an instance of the Website running on localhost, because I need to set some IDs for elements and don’t want to redeplloy the project everytime. The problem there is that I need to allow CORS for that to work. Whe manually testing I just run Chrome with --disable-web-security + some other arguments. Now my question is, can I set these arguments for the test recorder and tests, so that they use a Chrome instance with CORS allowed?
Currently I record the test on the deployed website, replace the XPATH with my IDs manually (Becasue thy don’t exists yet on the deployed website), download the test as Java Code and then set the WebDriver chromeOptions to use my CORS allowed instance. As you can probably guess that’s pretty tedious :smile:

Best regards,
Max

Hello @maximilian.broszio
You can not add them to the recorder at the time but you can add them to your test execution by using the Jobs custom capabilities feature.
For example, setting up camera permissions
You can create a new job, attach the test which requires the camera permission for example, and set costume capabilities to this job.

After creating a job an attaching the desired test, click on “set custom capabilities” icon:


and set it to:


which will automatically enable the camera permission for you.

So you can do the same thing with those arguments.

Hi @ran.tzur
Thank you for your help. It’s working for me and made the test creation a lot easier. Would be cool if that could be done with the test recorder as well!

Great to hear @maximilian.broszio
We will indeed work on it to include it in the recorder as well in the future.