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.

setValue() of input by ID with type='text' cuts off string.

See original GitHub issue

setValue of and input cuts off the entire string.

youtubeUrl = 'http://www.youtube.com/watch?v=YE7VzlLtp-4'
module.exports = {
  'Uploading a Youtube Video' : function ( browser ) {
    browser
     .setValue( "#video_url", youtubeUrl )
   }
};

Results in: http://www.youtube.com/watch?v=YE7Vzl

Cutting off the rest of the string.

As well as a vimeo movie: https://vimeo.com/1084537

Results in: https://vimeo.com/1

Although this seems to work:

youtubeUrl = 'https://www.youtube.com/123456789012345678910'

Any ideas if this is a bug or am I doing something incorrect?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Argon2000commented, Aug 11, 2016

So I ended up writing an extension command to nightwatch:

setValueSlow.js

exports.command = function (selector, value, using) {
    var self = this;
    self.elements(using || 'css selector', selector, function (elems) {
        elems.value.forEach(function (element) {
            for (var c of value.split('')) {
                self.elementIdValue(element.ELEMENT, c);
            }
        });
    });
    return this;
};

index.d.ts (typings extension since I’m using TypeScript):

declare module '~nightwatch/nightwatch' {
    export interface NightWatchBrowser {
        setValueSlow: (selector: string, value: string, using?: string) => NightWatchBrowser;
    }
}

Usage:

var username = 'integration@test.com';
browser.setValueSlow('input[ngcontrol=username]', username); //Works with ng2!
1reaction
santimendozacommented, Oct 22, 2018

I am using chromedriver version 2.35 and is happening with some inputs too. Any solution working right now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Losing text after a space setting the value in a new field
I give those text fields a string as a value. However, it is only working correctly if I give it a string with...
Read more >
<input type="text"> - HTML: HyperText Markup Language | MDN
Value. The value attribute is a string that contains the current value of the text entered into the text field. You can retrieve...
Read more >
HTML DOM Input Text value Property - W3Schools
The value property sets or returns the value of the value attribute of a text field. The value property contains the default value...
Read more >
Google Visualization API Reference | Charts
The output of this method can be used as input to DataView.setRows() to change the displayed set of rows in a visualization.
Read more >
Set the value of an input field in JavaScript - GeeksforGeeks
JavaScript setAttribute() Method: This method adds the specified attribute to an element and sets its specified value.
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