This is the code that habe no error:
perform() and reset_actions()
but these two functions have to work combinedly
import os
import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import random
# Setting the chrome_options
global chrome_options
chrome_options = Options()
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument('--profile-directory=Default')
prefs = {"profile.default_content_setting_values.notifications": 2}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument('disable-infobars')
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
google_search = [
"1.' driver.switch_to.active_element' ",
"2.this code is a one of important snippet for facebook automation.",
]
random_google_search = random.choice(google_search)
# Setting the Chrome Driver
global driver
driver = webdriver.Chrome("chromedriver.exe", chrome_options=chrome_options)
# Setting the Actions
global actions
actions = ActionChains(driver)
#the loop Running
def navigation():
time.sleep(5)
actions.reset_actions()
driver.get("https://google.com")
actions.send_keys(random_profile_post)
total_tab = 3
sleep_time = 1
implicitly_wait_time = 4
actions.reset_actions()
driver.implicitly_wait(implicitly_wait_time)
time.sleep(sleep_time)
for i in range(total_tab):
actions.send_keys(Keys.TAB)
print("Pressing * " + str(i + 1) + " * No Tab")
actions.send_keys(Keys.ENTER)
actions.perform()
for i in range(10):
navigation()
print("Pressing * " + str(i + 1) + " * st navigation function")
I am working with navigation() functions:
in the loop area
actions.send_keys(Keys.TAB)
actions.reset_actions()
I need to reset action but it's not reseating previous preform()
What will be the batter way to do that.
Please watch the youtube video for more clear understanding.
from perform() and reset_actions() in ActionChains not working selenium python
No comments:
Post a Comment