testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

For the SelectText function make start and end position part of the options object.

Open switch201 opened this issue 7 years ago • 4 comments

What is your Test Scenario?

I want to pass in some action options to the selectText function, but in order to do so i have to supply the start and end position for select text. the default start position is easy because its just 0 but the default end position states in the documentation: Length of the visible text content.. So in order to pass in the default value for end position I would have to figure out a way to get the length of the current text content, which I am sure is possible, it just seems like alot of work just so I can pass in some other options to this function.

What are you suggesting?

you should move those 2 parameters (start pos and end pos) into the options parameter so that way I don't have to re-pass in the default values.

What alternatives have you considered?

Additional context

My current work around is to simply pass in the value 100 for the end position because I don't think I have any text that will be that long.

switch201 avatar Oct 21 '19 19:10 switch201

You can pass undefined as an argument value to keep it default.

alexey-lin avatar Oct 22 '19 11:10 alexey-lin

Thank you Alex, I did not know that, is there somewhere in the documentation that states this? or is this something particular to JS I just didn't know about.

switch201 avatar Oct 22 '19 14:10 switch201

You are welcome. It's in JavaScript reference. For example, here:

Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.

alexey-lin avatar Oct 22 '19 14:10 alexey-lin

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

lock[bot] avatar Nov 01 '19 14:11 lock[bot]