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
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
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());
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);