I know I am doing something wrong. I need to create software to test a website. send_keys is working just fine for the rest of my code but I am not sure what I am doing wrong in this section. I have tried everything I can think of. I am very new to python and selenium so it's probably something silly.
Things I have tried:
1.
elem = lambda: driver.find_element_by_xpath('//textarea[@aria-label="Comment"]').click()
elem().click()
elem.send_keys("this is a comment")
elem.send_keys(Keys.RETURN)
2.
elem = lambda: driver.find_element_by_xpath('//span[@aria-label="Comment"]').click()
elem().click()
elem.send_keys("this is a comment")
elem.send_keys(Keys.RETURN)
3.
com_elem = driver.find_element_by_xpath('//textarea[@aria-label="Add a comment…"]')
com_elem.clear()
com_elem.send_keys("comment")
I have tried every combination I can think of and I know it needs to match the HTML but I have still tried it with lambda and without, with span and textarea (since it has a button you press that places your cursor in the text box) I do not know what else to try.
All it needs to do is click the text box, add words and hit enter.
this is HTML for the text box it needs to go inside of:
<form class="X7cDz" method="POST">
<textarea aria-label="Add a comment…" placeholder="Add a comment…" class="Ypffh" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>
<button class="sqdOP yWX7d y3zKF " type="submit">
Post
</button>
</form>
This is HTML for the button that it can click and the cursor will go in the box:
<span class="_15y0l">
<button class="dCJp8 afkep">
<span aria-label="Comment" class="glyphsSpriteComment__outline__24__grey_9 u-__7">
</span>
</button>
</span>
This part of the website works perfectly. I know because I have tested it by hand.