Add support for helper methods from specific browser drivers to Remote webdriver

64 views
Skip to first unread message

pavel.s...@gig.com

unread,
Dec 3, 2018, 4:52:56 AM12/3/18
to Selenium Users
Hi folks,

For example, we require access to CDP through remote driver. Currently, we're achieve this using a subclass "hack" like so:

class CDPSupportingRemote(webdriver.Remote):
   
"""
    Ensure driver supports `execute_cdp_cmd`

    copies command from chrome to remote driver
    selenium/webdriver/chrome/webdriver.py
    selenium/webdriver/remote/webdriver.py
    """

    execute_cdp_cmd
= webdriver.Chrome.execute_cdp_cmd

   
def __init__(self, *args, **kwargs):
       
super().__init__(*args, **kwargs)
       
self.command_executor._commands['executeCdpCommand'] = (
           
'POST', '/session/$sessionId/goog/cdp/execute'
       
)

Is this recommended? Is there a standard way to add some of the required capabilities to a Remote driver? If not, should there be a standard way, perhaps using mixins, or maybe some other mechanism?

Would appreciate a discussion on the subject, perhaps some comments from core devs as to the direction we want to take in Selenium?

Best Regards,
Pavel
Reply all
Reply to author
Forward
0 new messages