Apr-11-2020, 07:53 AM
Hello world,
I have the next function
print(" click again")
driver.find_element_by_xpath(f[i])
driver.find_element_by_xpath(f[i]).click()
because sometimes the python find and click, but the page is not loading, so
i create this second step for make sure the button is clicked, and works, but sometimes this is not working and looks I have to create another same code find....click()
Do you know why it happens, have one solution.
thank you world
I have the next function
f1="/html/body/div[2]/main/div....section[1]"
f2="/html/body/div[2]/main/div....section[2]"
f3="/html/body/div[2]/main/div....section[3]"...
f=[f1,f2,f3....]
b=0
try:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
d1=driver.find_element_by_xpath("/html/body/div[2]/..section[1]")
b=b+1
d2=driver.find_element_by_xpath("/html/body/div[2]/...section[2]")
b=b+1
d3=driver.find_element_by_xpath("/html/body/div[2]/...section[3]")
b=b+1....
except NoSuchElementException as e:
print("no more")
def my_function(i,driver):
while i<b:
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
import time
time.sleep(2)
element=driver.wait.until(EC.presence_of_element_located((By.XPATH,f[i])))
driver.find_element_by_xpath(f[i]).click()
try:
import time
time.sleep(1)
print(" click again")
driver.find_element_by_xpath(f[i])
driver.find_element_by_xpath(f[i]).click()
except NoSuchElementException as e:
print("no need double click ")
try:
myDynamicElement = driver.find_element_by_xpath("/html/section[8]/...input")
driver.find_element_by_xpath("/html/section[8]/...input").click()
except NoSuchElementException as e:
driver.wait.until(EC.presence_of_element_located((By.XPATH,"/html/section[9]/..input")))
driver.find_element_by_xpath("/html/section[9]/...input").click()
import time
time.sleep(2)
driver.back()
i=i+1
if b>0:
my_function(0,driver) and it runs perfect, the problem inside the function I need to have the second print(" click again")
driver.find_element_by_xpath(f[i])
driver.find_element_by_xpath(f[i]).click()
because sometimes the python find and click, but the page is not loading, so
i create this second step for make sure the button is clicked, and works, but sometimes this is not working and looks I have to create another same code find....click()
Do you know why it happens, have one solution.
thank you world
