Skip to content

Possible issue with clicking an "a" tag with target="_blank" in headless mode #866

@mdmintz

Description

@mdmintz

Possible issue with clicking an a tag with target="_blank" in headless mode.
This is supposed to always open a new tab/window. The behavior always works correctly in GUI mode.

Solution: Whenever performing a self.click() method in headless mode, capture the href, onclick, and target attributes of all a tags first. If the target is _blank and the href looks like a valid URL, first execute any script in onclick, then open a new tab, then navigate to the href in the new tab. This should reflect the same behavior as when performed in GUI mode.

Also, to keep the headless behavior consistent with the GUI behavior, the test should remain on the original tab/window, forcing the user to call a method such as self.switch_to_window(1) in order to switch to the new window. (There should also be a method called self.switch_to_newest_window(), which will become available in the SeleniumBase APIs at the same time that this issue is resolved.)

Metadata

Metadata

Assignees

Labels

bugUh oh... Something needs to be fixed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions