1

I want to know how to append link in current URL. For eg: me link is https://www.google.co.in/ in current program now I have to append /#q=ask+questions in this URL. Please help. I know how to get current url(by using getCurrentUrl() syntax)

Thanks

0

2 Answers 2

1

You could use URIBuilder. Something like this:

String someUrl = "https://www.google.co.in";
// or perhaps
// String someUrl = browser.getCurrentUrl();

URIBuilder uri = new URIBuilder(someUrl);
uri.setPath("search");
uri.addQueryParam("q", "ask+questions");

Assert.assertEquals(uri.toString(), "https://www.google.co.in/search?q=ask%2Bquestions");
// or perhaps
// browser.get(uri.toString());
Sign up to request clarification or add additional context in comments.

Comments

0

getCurrentUrlUrl() has a return type of String. So you can save it's value and play around like you can with any String.

Take an example, I want to get this url and then append your string and then get() this new webpage:

String url = driver.getCurrentUrl();
String newurl = url+"/#q=ask+questions";
driver.get(newurl);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.