Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
194
rated 0 times [  196] [ 2]  / answers: 1 / hits: 12137  / 10 Years ago, thu, september 18, 2014, 12:00:00

I found out that the default browser of casperjs is safari, because when I tried to access this site https://z1.expertchoice.com using casper and created a screenshot.



How can I change the default browser to chrome?


More From » casperjs

 Answers
19

CasperJS doesn't use Safari. In fact, it can only use PhantomJS and SlimerJS headless browsers for its automation. Therefore, it cannot work with Chrome either.



You are probably hitting a site that does user-agent detection. When a browser makes an HTTP request, it typically includes a request header called User-Agent which contains information used to identify the browser and other technologies and their versions. For instance:



User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36


As you have discovered, you can configure your user-agent string in CasperJS using:



casper.userAgent('Your User-Agent String Here');


There are many lists online of well known user-agent strings.


[#42432] Wednesday, September 17, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andreguym

Total Points: 125
Total Questions: 112
Total Answers: 103

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;