'Selenium can't make 2 try functions python
i can't get my code working, i need for code to try first element, then other element if there is neither of them then i need it to refresh browser and start again. Link is removed by me.
Code:
carnr = driver.find_element_by_xpath('//*[@id="rn_find"]')
piet = driver.find_element_by_xpath('//*[@id="doVRAA"]/a')
driver.get("https://link")
while True:
try:
carnr #1 lapa
carnr.send_keys(mnr)
carnrPoga = driver.find_element_by_name("RnFind").click()
break
except:
try:
piet.click() #TODO
break
except NoSuchElementException:
driver.refresh()
error code:
IndentationError: expected an indented block after 'except' statement on line 28
PS C:\Users\rektl\Desktop\csdd projekts> & C:/Users/rektl/AppData/Local/Programs/Python/Python310/python.exe "c:/Users/rektl/Desktop/csdd projekts/test3.py"
File "c:\Users\rektl\Desktop\csdd projekts\test3.py", line 29
driver.refresh()
^
IndentationError: expected an indented block after 'except' statement on line 28
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
