kaliiiiiiiiii/Selenium-Driverless

[feature request] TouchActions & ActionChains

nicostrebel opened this issue · 2 comments

I just stumbled across your projects and am currently trying to play with them.

Currently I'm running into an error that I'm not sure if it's a bug or I'm just being silly.
I use Slenium-Driverless with Selenium-Profiles as advised in the readme.
When i try to 'tap' an webelement python errors out and stops the execution and thinks i did not provide a webelement.
Here is where im not sure if i do something wrong or if there is an bug.

Traceback:

Traceback (most recent call last):
  File "C:\driverless.py", line 175, in <module>
    chain.move_to_element(firstName_elmt)
  File "C:\Python39\lib\site-packages\selenium_profiles\scripts\driver_utils.py", line 246, in move_to_element
    self.w3c_actions.pointer_action.move_to(to_element)
  File "C:\Python39\lib\site-packages\selenium\webdriver\common\actions\pointer_actions.py", line 87, in move_to
    raise AttributeError("move_to requires a WebElement")
AttributeError: move_to requires a WebElement

Here is my simplified code to understand what i did:

from time import sleep
from selenium_profiles.webdriver import Chrome
from selenium_profiles.profiles import profiles
from selenium_driverless.webdriver import ChromeOptions
from selenium_driverless.types.by import By
from selenium_driverless import webdriver
from selenium_profiles.scripts.driver_utils import TouchActionChain
    
def setDriver():
      profile = profiles.Windows()
      options = ChromeOptions()
      options.add_argument('--disable-dev-shm-usage')
      options.add_argument("--disable-popup-blocking")
      options.add_argument("--disable-notifications")
      options.add_argument('--ignore-ssl-errors=yes')

      driver = Chrome(profile=profile, options=options, driverless_options=True, injector_options=True)
    
      return driver

i = 0
while 20 > i:
      browser = setDriver()
      chain = TouchActionChain(browser)

       try:
           browser.set_page_load_timeout(50)
           browser.get('https://somelink')
       except:
           browser.quit()
           continue

       time.sleep(5)

       firstName_elmt = browser.find_element(By.NAME, "firstName")
       chain.tap(firstName_elmt)
       chain.perform()

Thanks for submitting this bug.
It occurs because selenium-driverless uses a custom WebElement and generic TouchActions probably require chromedriver.

Meaning, TouchActions aren't implemented for driverless yet.

For now, I'd recommend you to use bare javascript with driver.execute_script()

DEV

Possible implementations with

UPDATE
due to comment, I'll be implementing ActionChains with the cdp-Input-domain

move to #8