-1

I am trying to automate a test case in robot framework in which we are trying go to this link https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all and write a query in query editor. I am not able to do write query in query editor. Please help and thanks in advance.

*** Test Cases ***
query
    Open Browser    https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all    gc
    Input Text    //*[@id="tryitform"]/div/div[6]/div[1]/div/div/div/div[5]/pre[1]    Select * from tests

enter image description here

I guess i have to use some different keyword instead of "Input text" .

Ishan mahajan
  • 336
  • 1
  • 5
  • 15
  • You trying to input "SELECT * FROM tests" into the textarea within the W3Schools tutorial? – Goralight Apr 06 '17 at 11:09
  • What happens when you run your test? Do you get errors? Are you certain that the xpath is correct? is the input widget inside a frame? What else have you tried? – Bryan Oakley Apr 06 '17 at 11:24
  • @BryanOakley I am getting error " InvalidElementStateException: Message: invalid element state: Element must be user-editable in order to clear it." – Ishan mahajan Apr 06 '17 at 14:22
  • Have you done any research into that error? Error messages exist for a purpose: to give you hints as to what's wrong. At the time that I write this comment there are 25 questions on stackoverflow that mention this error message. Do none of them help you? – Bryan Oakley Apr 06 '17 at 14:25
  • @Goralight This is like query editor, where we can run our query online. – Ishan mahajan Apr 06 '17 at 14:55
  • @BryanOakley Yes i did some research. But still not able to fix it. Because this is not normal text area and i guess i have to use some other Keyword instead of Input text. – Ishan mahajan Apr 06 '17 at 14:58
  • @Ishanmahajan I'm not following... You have your own query editor - but you're using the W3Schools one? Also, the reason why you're getting that error is because you are trying to input text into a element which can't handle text being inputted to it... – Goralight Apr 06 '17 at 15:01
  • @BryanOakley Hi Bryan i am trying to do same thing in ace Editor, can you please guide me how you find codemirrror variable name(window.editor in this case) so that i can do the same thing there. – Ishan mahajan Apr 19 '17 at 15:38
  • You won't find the codemirror variable in an application using ace. Ace doesn't use codemirror. – Bryan Oakley Apr 19 '17 at 15:45
  • @BryanOakley I know. Actually i want to interact with ace editor(same way as we did here) how can i achieve that. – Ishan mahajan Apr 19 '17 at 15:49
  • I guess you start by reading some ace documentation. – Bryan Oakley Apr 19 '17 at 15:51
  • @BryanOakley Okay, thanks. – Ishan mahajan Apr 19 '17 at 15:56

1 Answers1

1

The problem you are encountering is that the text area isn't a standard html textarea widget. It is a codemirror editor, and I don't think you can directly interact with the codemirror editor using selenium commands.

What you can do instead is use the codemirror api to set the value in the editor. For example, the following works for me on the web page specified in your code example:

Execute javascript     window.editor.setValue('Select * from tests')

Note: this solution is highly dependent on the web page implementation. In this specific case, the web page is creating a javascript variable named window.editor which refers to the codemirror object. If you are trying to do this on some other page that uses codemirror, you might have to use some other method to get a reference to the codemirror object.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685