Estou a dois dias parada em uma linha de código somente, estou tentando da "enter" em um elemento mas ele sempre me retorna o erro
PS C:\Msg portabilidade> & C:/Users/TINETFLEX_ANABON/anaconda3/python.exe "c:/Msg portabilidade/Enviar WhatsApp Python.py"
Traceback (most recent call last):
File "c:\Msg portabilidade\Enviar WhatsApp Python.py", line 36, in <module>
while len(navegador.find_elements(By.ID, 'side')) < 1:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 772, in find_elements
return self.execute(Command.FIND_ELEMENTS, {"using": by, "value": value})["value"] or []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 348, in execute
self.error_handler.check_response(response)
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded
Stacktrace:
PS C:\Msg portabilidade> & C:/Users/TINETFLEX_ANABON/anaconda3/python.exe "c:/Msg portabilidade/Enviar WhatsApp Python.py"
Traceback (most recent call last):
File "c:\Msg portabilidade\Enviar WhatsApp Python.py", line 40, in <module>
contato = navegador.find_element(By.XPATH, ('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 742, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 348, in execute
self.error_handler.check_response(response)
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[@id="main"]/footer/div[1]/div[2]/div/div[2]; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:189:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:507:5
dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:132:16
# já estamos com o login feito no whatsapp web
for i, mensagem in enumerate(contatos_df['Mensagem']):
pessoa = contatos_df.loc[i, "Pessoa"]
numero = contatos_df.loc[i, "Número"]
texto = urllib.parse.quote(f"Oi {pessoa}! {mensagem}")
link = f"https://web.whatsapp.com/send?phone={numero}&text={texto}"
navegador.get(link)
while len(navegador.find_elements(By.ID, 'side')) < 1:
time.sleep(1)
#navegador.find_element(By.XPATH, '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]').send_keys(Keys.ENTER)
#element = navegador.find_element(By.xpath, '//*[@id="main"]').send_keys()
contato = navegador.find_element(By.XPATH, ('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]'))
contato.sendKeys(Keys.ENTER)
time.sleep(10)
navegador.find_elements(By.ID, 'side')
Pergunta
Ana Bon
Bom dia pessoal, tudo bem ?
Estou a dois dias parada em uma linha de código somente, estou tentando da "enter" em um elemento mas ele sempre me retorna o erro
PS C:\Msg portabilidade> & C:/Users/TINETFLEX_ANABON/anaconda3/python.exe "c:/Msg portabilidade/Enviar WhatsApp Python.py"
Traceback (most recent call last):
File "c:\Msg portabilidade\Enviar WhatsApp Python.py", line 36, in <module>
while len(navegador.find_elements(By.ID, 'side')) < 1:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 772, in find_elements
return self.execute(Command.FIND_ELEMENTS, {"using": by, "value": value})["value"] or []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 348, in execute
self.error_handler.check_response(response)
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchWindowException: Message: Browsing context has been discarded
Stacktrace:
PS C:\Msg portabilidade> & C:/Users/TINETFLEX_ANABON/anaconda3/python.exe "c:/Msg portabilidade/Enviar WhatsApp Python.py"
Traceback (most recent call last):
File "c:\Msg portabilidade\Enviar WhatsApp Python.py", line 40, in <module>
contato = navegador.find_element(By.XPATH, ('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 742, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 348, in execute
self.error_handler.check_response(response)
File "C:\Users\TINETFLEX_ANABON\anaconda3\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //*[@id="main"]/footer/div[1]/div[2]/div/div[2]; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8
WebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:189:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:507:5
dom.find/</<@chrome://remote/content/shared/DOM.sys.mjs:132:16
# já estamos com o login feito no whatsapp web for i, mensagem in enumerate(contatos_df['Mensagem']): pessoa = contatos_df.loc[i, "Pessoa"] numero = contatos_df.loc[i, "Número"] texto = urllib.parse.quote(f"Oi {pessoa}! {mensagem}") link = f"https://web.whatsapp.com/send?phone={numero}&text={texto}" navegador.get(link) while len(navegador.find_elements(By.ID, 'side')) < 1: time.sleep(1) #navegador.find_element(By.XPATH, '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]').send_keys(Keys.ENTER) #element = navegador.find_element(By.xpath, '//*[@id="main"]').send_keys() contato = navegador.find_element(By.XPATH, ('//*[@id="main"]/footer/div[1]/div[2]/div/div[2]')) contato.sendKeys(Keys.ENTER) time.sleep(10) navegador.find_elements(By.ID, 'side')
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.