How to get details of on which localhost karate UI test are running

Viewed 15

I am running a UI test in karate where I need to fetch the details of local host where test are running in karate, earlier I was using selenium to the same task with the following code

  ChromeOptions chromeOptions = new ChromeOptions();
  WebDriverManager.chromedriver().setup();
  ChromeDriver driver = new ChromeDriver(chromeOptions);
  HttpCommandExecutor executor = (HttpCommandExecutor) driver.getCommandExecutor();
  URL url = executor.getAddressOfRemoteServer();

And this url was returning

http://localhost:7150

Is there way to get these details in karate framework for UI tests.

1 Answers

I am able to fetch the port number from karate web driver

 * def opt = driver.getOptions()
 * def port =  opt.port

And then appending to string "http://localhost:"+port which solves the problem.

Related