Sendkeys Actions将在第二个循环周期执行期间重新输入先前的值

时间:2019-07-09 08:44:12

标签: python-3.x selenium-webdriver

在循环的第一个执行期间,正在输入getTotal的数据“ actions.send_keys(Keys.CLEAR).send_keys(getTotal()).send_keys(Keys.ENTER).perform()”可以,但是在下一个循环执行周期将在输入当前值之前重新输入getTotal的先前数据。

for i in range( 1000 ):
    try :
        # Enter the answer
        answer = driver.find_element_by_xpath( "//div[@class='_1mf _1mj']" )
        # driver.find_element(By.XPATH,"//div[@class='_1mf _1mj']").send_keys(ans)
        answer = actions.send_keys( Keys.CLEAR ).send_keys( getTotal() ).send_keys( Keys.ENTER ).perform()
        print( 'Answer has been entered' )
        time.sleep( 15 )

    except TimeoutError as e:
        print( e )
        print( "Element has not found" )
        driver.quit()

0 个答案:

没有答案