I'm trying to get user-agent information for browsers in selenium,java.I tried "HttpServletRequest "and find a method like as below.Which parameter should I give for "HttpServletRequest request"? is it url?
private String getUserAgent(HttpServletRequest request) {
return request.getHeader("user-agent");
}
Also ,is there anyway to get user-agent in selenium like as javascript? Thanx.
String userAgent = (String) ((JavascriptExecutor) driver).executeScript("return navigator.userAgent;");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With