0

I'm currently facing an issue related to input values in code mirror (FYI: input is html code)

Any help much appreciated!!

This is what i was doing so far (but i need to insert values in each line of code mirror)

JavascriptExecutor js = (JavascriptExecutor)driver;
Js.executeScript("arguments[0].CodeMirror.setValue(\"" + value + "\");", driver.findElementBy(By.id("id")));

enter image description here

Page source code is:

<div class="CodeMirror cm-s-default">
<div style="overflow: hidden; position: relative; width: 3px; height: 0px; top: 5px; left: 35px;">
<textarea wrap="off" style="position: absolute; padding: 0px; width: 1px; height: 1em; outline: medium none;" autocorrect="off" autocapitalize="off" spellcheck="false" tabindex="0"></textarea>
</div>
<div class="CodeMirror-vscrollbar" cm-not-content="true" style="min-width: 18px;">
<div style="min-width: 1px; height: 0px;"></div>
</div>
<div class="CodeMirror-hscrollbar" cm-not-content="true" style="min-height: 18px;">
<div style="height: 100%; min-height: 1px; width: 0px;"></div>
</div>
<div class="CodeMirror-scrollbar-filler" cm-not-content="true"></div>
<div class="CodeMirror-gutter-filler" cm-not-content="true"></div>
<div class="CodeMirror-scroll" tabindex="-1" draggable="true">
<div class="CodeMirror-sizer" style="margin-left: 30px; margin-bottom: 0px; border-right-width: 30px; min-height: 31px; min-width: 7px; padding-right: 0px; padding-bottom: 0px;">
<div style="position: relative; top: 0px;">
<div class="CodeMirror-lines">
<div style="position: relative; outline: medium none;">
<div class="CodeMirror-measure">
<span>
<span>​</span>
x
</span>
</div>
<div class="CodeMirror-measure"></div>
<div style="position: relative; z-index: 1;"></div>
<div class="CodeMirror-cursors">
<div class="CodeMirror-cursor" style="left: 4px; top: 0px; height: 22.85px;"> </div>
</div>
<div class="CodeMirror-code">
<div style="position: relative;">
<div class="CodeMirror-gutter-wrapper" style="left: -30px;">
<div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">1</div>
</div>
<pre class=" CodeMirror-line ">
<span>
<span cm-text="">​</span>
</span>
</pre>
</div>
</div>
</div>
</div>
</div>
</div>

So the problem is how to input value in different lines in code mirror..

6
  • 'input values are html code' - dont you think write this html Would be bad idea? Commented Jun 22, 2016 at 11:51
  • @kotoj yeah it's a bad idea, but we've requirement to do so.. i'm trying to input html to code mirror it's just adding it in one line.. Commented Jun 22, 2016 at 12:41
  • I mean you should attach this html to your question... Commented Jun 22, 2016 at 14:47
  • updated my question.. Commented Jun 22, 2016 at 14:52
  • So what is your problem? Commented Jun 22, 2016 at 14:55

2 Answers 2

1

Your question is not very clear but I think what you are looking for is to insert text into different lines instead of all on one line. If that's the case, you need to insert \n in your string where you want carriage returns.

An example string would be string sample = "<html>\n <test>\n</html>" which should produce

<html>
  <test>
</html>
Sign up to request clarification or add additional context in comments.

3 Comments

I can't see your code so I can't help you. Have you googled "unterminated string literal" and found common causes and examined your code for any of those causes?
was using jsexecutor to input value in code mirror.. following exactly same code
I'm able to input values in code mirror with line breaks using \\r.. Thanks @JeffC for your time
0

I'm able to input code mirror with line breaks, by changing the input value to this.. <html>\\r<test>\\r</html>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.