question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing setValue for div with contentEditable

See original GitHub issue

The code below doesn’t work because the #cv-paste element is a div with content editable browser. Is there a way set an innerHTML of an element and then be able to check it?

.setValue('#cv-paste', 'my cv text my cv text my cv text my cv text')
.assert.value("#cv-paste", "my cv text my cv text my cv text my cv text")

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
pastdevrcommented, Feb 28, 2019

@andre0799, I think a proper way to accomplish this through a combination of click and keys commands. click to make element active and editable and keys to type some text.

.click('#cv-paste')
.keys('my cv text my cv text my cv text my cv text'.split(''))

keys accepts a sequence of key strokes, so split will help with this.

0reactions
lmj0011commented, Dec 31, 2017

in case anyone stumbles here because they’re trying to set content inside an tinymce editor from nightwatch

I managed to use the execute() command to get to the tinyMCE frame and just set the innerHTML of the tinyMCE to what i wanted

.execute(`
var x = document.getElementById("Body1_ifr");  
var y = (x.contentWindow || x.contentDocument); 

if (y.document) {
 y = y.document;  
}

y.body.innerHTML = "Article body";
`)

see: https://stackoverflow.com/a/27362212/2445763

Read more comments on GitHub >

github_iconTop Results From Across the Web

change contenteditable value with js - Stack Overflow
You can't put anything inside an input element. It's a self-closing tag. This is not valid markup and therefore the question is moot....
Read more >
About the State Management of a Contenteditable Element in ...
What if we want to have the current value of the editable content in a state variable? Start by adding such a state...
Read more >
Contenteditable attribute - HTML 5
The isContentEditable DOM attribute, on getting, must return true if the element is editable, and false otherwise. If an element is editable and...
Read more >
contenteditable - HTML: HyperText Markup Language | MDN
Chrome Edge contenteditable Full support. ChromeYes. Toggle history Full suppo... contenteditable="caret". Experimental Full support. ChromeYes. Toggle history Full suppo... contenteditable="events". Experimental Full support. ChromeYes. Toggle history...
Read more >
Easy JavaScript/jQuery Input Mask Plugin - inputmask
Call the plugin on the target element and done. ... Fixed "[object Object]" value after $element.inputmask('setvalue', '') call; Fixed: Lost ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found