Is there a way to identify if a HTTP request was send using Selenium?
For example if Selenium adds any request header, cookie or equivalent?
I tried looking at the User Agent, but it didn't reveal anything about Selenium:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
I noticed that HTTP_X_FORWARDED_FOR gets set if Selenium is being used:
HTTP_X_FORWARDED_FOR => 0:0:0:0:0:0:0:1%0
Nope. Selenium doesn't mark its requests with anything.
Related
TL;DR: Safari on Desktop sent a single request with an iPhone user agent and without cookies, and we don't know why. It uses FOUR different user agents.
I was using Safari 16.1 on macOS Ventura 13.1 to test a website that I built.
I found a strange request with an iPhone User Agent string in the server access log.
This request did not include any cookies, causing my session to end.
I am convinced that the request came from my browser because:
It is from my IP address, and I'm the only one here.
The request was 1 second before a request that I know I made, for the same URL.
The URL is several steps into a checkout process, so it is unlikely to be reached any other way (e.g. bots).
Requests before and after it had my expected desktop user agent (see screenshot).
But what is strange is:
There is only one request logged with the iPhone user agent string.
There are no iPhones or other Apple devices at this IP address, just a MacBook Air.
Safari can emulate other user agents, but I have never used that feature in Safari.
I did have the Safari Web Inspector open at the time, to watch a cookie.
The URL outputs some content with a JavaScript redirect, so it is actually not possible to stay on it to refresh it.
So why did desktop Safari change the user agent string to iPhone for a single request?
Is there some keyboard shortcut for switching user agent that I could have pressed accidentally?
Or is this a known behaviour of Safari? (like this other surprising user agent change)
UPDATE: During a short session, after updating to macOS Ventura 13.2 and Safari 16.3, Safari used 4 different user agents.
1 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15"
2 "Safari/18614.4.6.1.5 CFNetwork/1404.0.5 Darwin/22.3.0"
3 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)"
4 "Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1"
(1) is the main user agent reported by most tools.
(2) requests apple-touch-icons, and I understand it.
(3) is a little shorter than the main one, and made only 3 simultaneous requests at the start of my session.
(4) contains "iPhone", and made 3 simultaneous requests at the same time as (3).
My selenium script is not working on headless mode but working fine without headless. Error msg (NoSuchElementException)?why?
Increase time.sleep 2 to 10 but still not working
Some of the applications do not work properly in the headless mode due to the application firewall. In that case, you need to debug what is showing inside headless.
Take a snapshot using selenium and see what is showing before the element
not found exception
If you found your application is blocked to load in headless then follow the steps
To bypass the firewall you can use following argument in your python script. I used it in my java so i mention it in java. You can convert to your desire language
options.addArguments("--headless");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36");
I'd like to use Chrome to emulate different devices to run my frontend tests on different emulators. in the documentation, I found the following example
And driver.emulateDevice(375, 812, 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1')
where can I get a list of different options?
That is completely up to you, Karate just takes the string you provide and uses it "as is".
For further research into what that string is all about, you can refer this: https://wicg.github.io/ua-client-hints/
I'm trying to make a file download app using vb.net but when i debug the app and press the button i see this error. How can i solve this problem ?
MY CODE :
ERROR :
Looks like thinkbroadband's server doesn't like serving that file to things it considers bots/not real browsers. You'll have to mimic a real browser instead:
Dim x As New WebClient
x.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Edg/83.0.478.45")
x.DownloadFile("http://download.thinkbroadband.com/10MB.zip", "c:\temp\a.zip")
How did I know this? I opened my browser developer tools (F12), downloaded the file OK in the browser and looked at what headers were sent for an OK result, then pared it down to just the important one (useragent)
I wouldn't really want to bother you here, but as I don't have a mac I cannot test this.
I made a browser sniffing class (I know it's bad but it works well and is not the point).
This all works fine, however my colleague said there was a bugg on a website I recently did.
All I would like to know / see is if there is a link to any website that has the Safari 7 useragent string documented / raw or if someone could post the Safari 7 UA string here ($_SERVER['HTTP_USER_AGENT'] in PHP).
I checked for this on google and websites as useragentstring.com, but cant get the UA from there either.
Thanks in advance.
Found it:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9) AppleWebKit/537.71 (KHTML, like Gecko) Version/7.0 Safari/537.71