0

So I have this function that drives to a website and clicks a bunch of stuff.

I would like the y variable to increment by +20 every time the loop completes.

The y value is in the last set of coordinates for the autogui clicks at the end. I think the incrementation would happen just after the function completes a cycle, or just before or after the for loop?

def tagger(var1, var2,y):
    driver = webdriver.Chrome('/Users/name/Desktop/chromedriver')

    driver.get('https://exampewebsite')
    time.sleep(5)

    driver.find_element_by_xpath('/html/body/div[1]/form/div/div/input[1]').send_keys('example')
    driver.find_element_by_xpath('/html/body/div[1]/form/div/div/input[2]').send_keys('example')
    driver.find_element_by_xpath('/html/body/div[1]/form/div/button').click()
    time.sleep(5)

    driver.find_element_by_xpath('//*[@id="dropdownMenu2"]').click()
    time.sleep(2)
    driver.find_element_by_xpath('/html/body/div[1]/div[1]/button').click()
    time.sleep(2)
    driver.find_element_by_xpath('//*[@id="session-name"]').send_keys(var1)
    driver.find_element_by_xpath('//*[@id="session-tv"]').send_keys('https:example'+var2)
    driver.find_element_by_xpath('//*[@id="session-comment"]').send_keys('https://example', '\n', 'Just added clicks')
    driver.find_element_by_xpath('//*[@id="btnSaveNew"]').click()
    time.sleep(2)
    driver.find_element_by_xpath('//*[@id="editBlock"]/label/span').click()
    time.sleep(5)

    driver.find_element_by_xpath("//*[@id='words_tabs']/div/span").click()

    time.sleep(2)
    pyautogui.doubleClick(433, -800, duration=1)
    pyautogui.press('enter')
    pyautogui.doubleClick(433, -740, duration=1)
    pyautogui.press('enter')
    pyautogui.doubleClick(420, y,duration=1)
    pyautogui.press('enter')
    time.sleep(30)



    driver.quit() 

    for key, value in mydict.items():
         tagger(str(key), str(value), -884 )

Anwarvic
  • 12,156
  • 4
  • 49
  • 69
Digital Moniker
  • 281
  • 1
  • 12

1 Answers1

1

Outside the function, you can declare

y = 0

And inside the function, in the first line you can say this:

def tagger(var1, var2):
    global y
    ...your code
    y+=20

This way, the y value will remain throughout

OlorinIstari
  • 537
  • 5
  • 20