Python selenium ActionChains Pre-Run Action Repeat Error

Asked 2 years ago, Updated 2 years ago, 38 views

Currently, we have proceeded with the address input and search function, but there is an error, so I am asking you this question.

I have used Selenium ActoinChains several times.

You are using action.reset_actions to initialize each action.

Repeat the previous content without initializing the action.

Also, after entering the address, it runs only from the command statement that executes the enter button to entering the address.

The enter button is executed in the action.reset_actions statement.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
driver = webdriver.Chrome()

You must insert a path into webdriver.Chrome(), but omit it because the path is the same as the current path.


driver.get('https://map.naver.com/v5/directions/-/-/-/carc=14070528.1667352,4364176.3814983,6,0,0,0,dh')

action = ActionChains(driver)
start = driver.find_element_by_xpath('//*[@id="directionStart0"]')
end = driver.find_element_by_xpath('//*[@id="directionGoal1"]')
search = driver.find_element_by_xpath('//*[@id="container"]/shrinkable-layout/div/directions-layout/directions-result/div/directions-search/div[2]/button[3]')

action.move_to_element(start).send_keys ('513 Yeongdong-daero, Gangnam-gu, Seoul')key_down(Keys.ENTER).perform()
action.reset_actions()

action.move_to_element(end).click().send_keys ('San 144-4 Seocho-dong, Seocho-gu, Seoul')key_down(Keys.ENTER).perform()
action.reset_actions()

action.move_to_element(search).click().perform()
action.reset_actions()
    def reset_actions(self):
        """
            Clears actions that are already stored on the remote end.
            Clears actions that are already stored locally and on the remote end
        """
        if self._driver.w3c:
            self._driver.execute(Command.W3C_CLEAR_ACTIONS)
        else:
            self._actions = []
            self.w3c_actions.clear_actions()
        self._actions = []

python selenium

2022-09-20 20:20

1 Answers

I can't initialize it the same way, but once you declare action with action = ActionChains (driver) as a temporary measure, it will be initialized ;;;;;


2022-09-20 20:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.