teodesian / Selenium-Remote-Driver

Perl Bindings to the Selenium Webdriver server
173 stars 91 forks source link

Why are certain capabilities in Selenium/Firefox/webdriver_prefs.json frozen? #469

Closed tod222 closed 3 years ago

tod222 commented 3 years ago

Specifically:

    "browser.link.open_external": 2,
    "browser.link.open_newwindow": 2,

We need to change newwindow to 3 to always open in a new tab, but these frozen capabilities prevent that.

teodesian commented 3 years ago

Probably because there is no way, and has never been a way to page between tabs via either the JSONWire or WC3 selenium spec.

Open new tabs all you like, so long as you want to be unable to interact with them.

Does whacking them from webdriver_prefs.json fix it nonetheless? AFAIK this is the default behavior on newer driver binaries and the seleniumhq jar, so it's probably not needed to freeze this any longer; if users wanna footgun I probably shouldn't prevent them from doing so.

tod222 commented 3 years ago

Interesting. Nobody told us it was impossible so we've been doing it for ~2 years. Pretty sure we started back before needing to patch Selenium/Firefox/webdriver_prefs.json. open_window_in_new_tab_and_switch_to_it

teodesian commented 3 years ago

So, you are just using switch_to_window, and the browser vendors have made that actually switch tab instead of exploding like it used to for years.

I'm curious, what does new tabs get you over and above a new window? If you interact with it the same way you do a new window, I don't see any real benefit.

Nevertheless, if the browser vendors have started supporting this, I have no objection to removing this, I just don't see that it's hurting anything (but would love to hear a reason).

tod222 commented 3 years ago

A tab comes up in the main window at the same size as the previous tab. In our experience a new separate window comes up with an arbitrary size, usually smaller than the main window. With small windows elements are more likely to be offscreen and thus generate errors when clicked due to all the inconvenient sanity checking that came with Quantum.

teodesian commented 3 years ago

It's not only inconvenient, but even does it's check incorrectly when negative margins are involved. I resorted in my own code to only doing click() with javascript because of such nonsense.

Anyways, I generally have avoided this by wrapping all window handling code to paranoidly maximize everything. (the reason I maximize is also because the dimension setting methods appear to work randomly if at all. Really is an amazing framework this selenium).

That said, timtowtdi, so I'll make a patch to waste the frozen prefs. It doesn't look like it's really needed anymore.