-1
我想包括一個if語句在我的硒for循環函數中點擊並作爲任務應用,但是,以代碼的寫入方式,它只是跳過一切if語句之後,重新開始循環Python - 如果語句跳到下一個循環
for i in loop:
# Enter username and password
driver.find_element_by_name('_username').send_keys(username)
driver.find_element_by_name('_password').send_keys(password)
driver.find_element_by_id('buttonSubmit__login').click()
# If statement to skip to next loop
if driver.find_element_by_xpath('// [@id="messageGroup"]/div[2]/div/span'):
continue
# Do stuff
換句話說,我會繼續努力,輸入用戶名和密碼,而不是將代碼的下一階段。有什麼建議麼?
我剛剛使用'break'語句,它所做的只是暫停'for循環' – user2105555
沒關係,只是想通了。謝謝,@丹尼爾。 – user2105555