-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] Specify headers #3
Comments
(ps : the idea is to be able to set the "Accept-Language" header to something like "fr") |
AFAIK, this is not possible, since selenium only drives the browser. An alternative is to modify the headers on the browser i.e. by using the Modify Headers addon for firefox. |
I tried using the Modify Headers addon for firefox and it works great when I open it up by hand, but whenever I run it through Selenium it tells me that the Modify Headers addon is "Not compatible with Firefox 3.5.8". I'm not sure what the problem is. Does Selenium automatically disable this addon for firefox or am I just missing something? Any ideas? |
You'll need to create a Firefox profile just for Selenium. Add the Modify Headers addon to that profile. Then tell Selenium RC server to use this profile, i.e.: |
Ok, So I have done all of that. I created a selenium profile and I'm using the selenium-rc gem so the way I start selenium looks like this: selenium-rc -debug -timeout 60 -firefoxProfileTemplate "/home/scnaegl/.mozilla/firefox/4ufai4g9.selenium/" However, just to make sure, I went and got the profile switcher addon for firefox from here: https://nic-nac-project.org/~kaosmos/profileswitcher-en.html I installed the profile switcher addon on my default profile first and when I ran the selenium it didn't show as if I even had the addon. Then I installed the addon for my selenium profile and ran it again. This time, I could see that the profile switcher addon was indeed installed, however it showed as not having any profile at all. So here is how I am setting up the Selenium Client Driver if that helps: $selenium = Selenium::Client::Driver.new( I have tried using :browser => "*custom /usr/lib/firefox-3.5.8/firefox -P selenium" but whenever I do that the browser comes up, but the second browser for selenium controls never comes up and it just hangs and eventually times out. I'm not sure what I am doing wrong, but as you can see I've tried all kinds of things and nothing seems to work completely. |
Hallo, I'm having exactly the same problem, did you manage to solve it? |
Oh good, so someone else is having the same problem and I'm not just crazy lol Well I haven't been able to fix the problem yet. I've run out of ideas and I'm hesitating trying to drill into the heart of the java selenium source, which is where I think the problem really is. Let me know if you come up with a solution. |
I'm having the exact same problem. Did anyone ever manage to fix this issue? It's a total showstopper for my use of Selenium RC. |
The Modify Headers add-on will have to be installed by manually launching your Firefox profile for selenium first. If you add the Modify Headers add-on during a Selenium RC session, it will be discarded after you close Selenium RC. Here are the steps:
java -jar selenium-server.jar -firefoxProfileTemplate "/home/user/path/to/selenium_profile" I hope this helps. |
Thanks for the quick reply, aptinio! Unfortunately, I already did exactly that, and it didn't help. My initial problem was in fact because of the way selenium uses a throw-away profile unless told otherwise, but I figured that out and did the steps you described to make a profile specifcally for Selenium RC to use. However, even when Selenium was using this profile (I could tell it worked because Firebug is installed and working when Selenium runs my tests), Modify Headers still didn't work. For some reason Firefox considers Modify Headers to be "Incompatible with Firefox 3.6.10" when Selenium launches the browser. However, when I launch it, using firefox -P selenium_profile, Modify Headers works fine. I can only assume that this is some kind of bug in Selenium RC. |
Ah HA! I posted on the selenium-users google group, and a wonderful responder showed me how to get around this issue with Modify Headers. There is an API in the Selenium RC client driver that allows us to specify custom headers. Here's how to do it in python code: It should be fairly similar in other languages. Until this problem with Modify Headers being erroneously detected as incompatible is resolved, this seems to be the only way to get custom headers in your HTTP requests for Selenium RC tests. |
There's one more thing you can possibly try: Disable extension compatibility checking in Firefox (using your Selenium profile): http://kb.mozillazine.org/Extensions.checkCompatibility
|
Hi,
would it be possible to define custom headers for selenium-client ?
I'm especially thinking to something like the webrat header method (http://gitrdoc.com/rdoc/brynary/webrat/481bfe03c0829a7d858443ceb6a51e1587a0d931/classes/Webrat/Session.html#M000101)
Ex : header
Thanks !
The text was updated successfully, but these errors were encountered: