Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. global dropdown_counter
  2. dropdown_counter = 1
  3. global str_counter
  4. str_counter = str(dropdown_counter)
  5. global dropdown_link
  6. def open_dropdowns(xpath):
  7. for _ in range(23):
  8. str_counter = str(dropdown_counter)
  9. dropdown_link = '/html/body/div[1]/div/div[2]/div/div/div[2]/div[1]/nav/div/div/div/div/div[2]/ol/li[' + str_counter + xpath
  10. driver.find_element_by_xpath(dropdown_link).click()
  11. dropdown_counter +=1
  12. dropdown_counter = 1
  13. open_dropdowns(']/span/button')
  14. open_dropdowns(']/ol/li[1]/span/button')
  15.  
  16. '''
  17. I defined all the variables as global but im still getting this error
  18.  
  19.  
  20. Traceback (most recent call last):
  21. File ".\ustech.py", line 58, in <module>
  22. open_dropdowns(']/span/button')
  23. File ".\ustech.py", line 53, in open_dropdowns
  24. str_counter = str(dropdown_counter)
  25. UnboundLocalError: local variable 'dropdown_counter' referenced before assignment
  26.  
  27. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement