Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Best way to add query param to all navigations

I am looking for a solution to add query param on each URL after navigation using WebDriverIO.

For example: Base URL: https://www.google.com/?block=true

When I click a button on the page loaded from the above URL, new URL that loads is https://www.google.com/search-page.

I would like to append ?block=true to all the navigations.

For the base URL, I can use the method browser.url("https://www.google.com/?block=true"). Not sure how I can add to other pages that are navigated using click actions.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use URLSearchParams to generate complex search params. Check out the below example.

const baseUrl = "https://www.google.com/?block=true"; // window.location.href
const searchUrl = "https://www.google.com/search?test=testparam";

function getRedirectUrl(baseUrl, newUrl) {
  let oldParms = new URL(baseUrl).searchParams;
  const newUrlParams = new URL(newUrl).searchParams;
  for(let [value, key] of oldParms.entries()){
    newUrlParams.append(key, value);
  }
  const newSearch = new URL(newUrl).search;
  return `${newUrl.slice(0, -1 * newSearch.length)}?${newUrlParams.toString()}`;
}

console.log(getRedirectUrl(baseUrl, searchUrl));

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!