I'm trying to find a textarea in my facebook group. The login is ok, driver.get(group)
is ok too but then, when I try to locate the textarea, it returns that it can't locate it. The weird thing is that I can clearly see it there.
def send_post(self,text,group):
assert self.logged == True
self.driver.get(group)
text_field = self.driver.find_element_by_css_selector('div.innerWrap').find_element_by_tag_name('xhpc_message_text')
text_field.send_keys(text)
self.driver.find_element_by_xpath("//button[@value='1']").click()
Do you know what am I doing wrong? Do you have a better way to post to fb group?
xhpc_message_text
isn't a tag name; textarea
is.
If you're talking about the post-writing <textarea>
, then it has a name
attribute (different!) of xhpc_message_text
. You can combine your find_element_by_*
calls into one:
text_field = self.driver.find_element_by_css_selector('div.innerWrap [name="xhpc_message_text"]')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.