1

I'm using arsenic and I've been trying to simulate the Ctrl+click to open a link in a new tab. When I run the code below, it results in a "AttributeError: 'Tick' object has no attribute 'mouse'"

import asyncio
import sys
from arsenic import get_session, keys, browsers, services
from arsenic.actions import chain, Keyboard, Mouse, Button

GECKODRIVER = r'C:/bin/geckodriver.exe'
chromedriver = r'C:/bin/chromedriver.exe'

async def hello_world():
    service = services.Chromedriver(binary=chromedriver)
    browser = browsers.Chrome()
    async with get_session(service, browser) as session:
        await session.get('https://duckduckgo.com/?q=arsenal')
        match = await session.get_element("(//div[@class='module--carousel__body'])[1]", "xpath")

        Key = Keyboard()
        mouse = Mouse()

        actions =  chain(
            Key.down(keys.CONTROL) | mouse.move_to(match).mouse.down() | Key.up(keys.CONTROL)
            
        )
        await session.perform_actions(actions)
   
async def main():
    await asyncio.gather(hello_world())    
    
if __name__ == '__main__':
    asyncio.run(main())
   
Drex
  • 11
  • 1

0 Answers0