How to set the user agent in selenium tests

1 min


643
1 comment, 643 points
user agent in selenium tests
user agent in selenium tests

How to set the user agent in selenium tests

What is a User Agent?

You might have to set different type of user agents , so today we will cover how to set the user agent in selenium tests.

The User-Agent HTTP header identifies the client and is sent by “regular” browsers, search engine crawlers, or other web client software.

Given /^my user agent is "(.+)"$/ do |agent|
  page.driver.browser.header('User-Agent', agent)
end

If you want to use firefox you should check first this stackoverflow article .

When you are using Chrome, you can spawn a new Chrome using the --user-agent command line switch.

Happy Testing!


Like it? Share with your friends!

643
1 comment, 643 points

What's Your Reaction?

cute cute
0
cute
scary scary
0
scary
wtf wtf
0
wtf
geek geek
0
geek
WIN WIN
0
WIN
Love Love
0
Love
OMG OMG
0
OMG
Angry Angry
0
Angry
Lol Lol
0
Lol
Test engineer

One Comment

Your email address will not be published. Required fields are marked *

Choose A Format
Trivia quiz
Story