Reputation: 55
all trust that you're well I'm trying to inspect the textarea of the Instagram Direct Message section using selenium, however, my attempts in finding the path have been unsuccessful, would appreciate any help I can get.
txt_box = bot.find_element_by_xpath('/html/body/div[1]/section/div/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/div[2]/textarea')
txt_box.send_keys(f"Hey @{user}") # Customize your message
Error I receive upon running the code:
txt_box = bot.find_element_by_xpath('//textarea[@placeholder="Message..."]')
Exception in thread Test 1:
Traceback (most recent call last):
File "C:\Users\veron.000\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\veron.000\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "c:\Users\veron.000\Desktop\Eros\Instagram\Instgram Dm v1\Final\Multi_Dm.py", line 83, in test_instance
send_msg(usrnamee)
File "c:\Users\veron.000\Desktop\Eros\Instagram\Instgram Dm v1\Final\Multi_Dm.py", line 73, in send_msg
txt_box.send_keys(f"Hey @{user}, I'm Jordan from ARICCI’s Talent Recruitment in London.\nWe’re an upcoming sunglasses brand and we would love to see you in our new pieces!\n\nWould you be down for promoting us and earning FREE products, BIG commissions, and getting featured on our official Instagram page?\n\n👉 DM us @ariccirecruiter to get started! Offer runs out in 48 hours. ⏳") # Customize your message
File "C:\Users\veron.000\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 540, in send_keys
self._execute(Command.SEND_KEYS_TO_ELEMENT,
File "C:\Users\veron.000\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webelement.py", line 710, in _execute
return self._parent.execute(command, params)
File "C:\Users\veron.000\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute
Upvotes: 0
Views: 919
Reputation: 142824
Full error message shows that there is no problem with finding textarea
.
There is only warning
that in next version you will have to use find_element(By.XPATH)
.
The real problem makes send_key()
. It seems it has problem to send some chars.
Probabaly it has problem to send emoji
- so try without emoji
.
Upvotes: 1