Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having trouble clearing tinymce textarea with selenium

In selenium I want to enter some text into the tinymce text area, but I'm having trouble clearing the textarea before putting in my text.

The clear function that usually work well to remove preexisting texts in a "normal" input area dosn't seem to work for a tinymce textarea

like image 206
SLq Avatar asked Mar 21 '23 11:03

SLq


1 Answers

If you show your current attempts it would be possible to fix them. Have you inspected the page's source code to make sure you're in the right frame and selecting the right element?

Generally speaking you can clear a textbox/textarea/whatnot by seleniums clear() function, like this:

1. driver.find_element_by_id("id of textbox").clear()

or 2. driver.find_element_by_css_selector("#...").clear()

etc etc

If this does not work the error message generated will normally be a useful indicator at what's wrong.

If you however are sure you're really selecting the right element of the page, you might be doing the common mistake of trying to select something lying inside an iframe, without first having switched to this iframe.

This is done by:

driver.switch_to_frame("frame name") #switch to the iframe

#do what you want to do inside the iframe. for example: 
driver.find_element_by_id("textbox id").clear() #clear the textbox
#write something to the textbox

driver.switch_to_default_content() #switch back from the iframe when you're done
like image 182
RobinKarlsson Avatar answered Apr 01 '23 07:04

RobinKarlsson