WebdriverIO - characters being stripped out of string - selenium

This may be a long shot but I'm seeing the weirdest thing. I'm using the setValue and addValue functions from WebdriverIO and whenever my string contains the number 3, it is being stripped out and not entered into the input boxes. I am manually able to type 3 into these inputs so I have no idea what is going on. 3 is the only character I've seen this happen with.
Any ideas?
Update: This is only occurring in Chrome
Update 2: Sorry for the lack of details. Here is additional info. I'm using wdio test runner. This issue does not occur in Safari or Firefox, only in chrome.
browser.setValue(usernameInput, "t3st") will input "tst" into the usernameInput element. As well
browser.addValue(usernameInput, "t3st"). Any string containing a 3 will be inputted to any element, but all 3's will be missing from the string.
package.json dependencies:
"dependencies": {
"babel-preset-es2015": "~6.24.0",
"babel-register": "~6.26.0",
"chai": "~4.1.2",
"chromedriver": "^2.33.2",
"wdio-cucumber-framework": "~1.0.2",
"wdio-phantomjs-service": "~0.2.2",
"wdio-selenium-standalone-service": "~0.0.9",
"wdio-spec-reporter": "~0.1.2",
"webdriverio": "4.7.1"
},
"devDependencies": {
"babel-jest": "~21.2.0",
"babel-polyfill": "~6.26.0",
"eslint": "~4.9.0",
"eslint-config-airbnb-base": "~12.1.0",
"eslint-plugin-import": "~2.8.0",
"forever": "~0.15.3",
"http-server": "~0.10.0",
"jest": "~21.2.0"
}

Well, I had a look, but didn't manage to reproduce it. I tried both of the bellow examples using different variants of chromedriver, or wdio-selenium-standalone-service. All worked just fine.
My guess is that:
maybe that input you're trying to fill in has some JavaScript logic behind (form-validation) which might be truncating digits;
or, maybe you have some old software (outdated packages) from your package.json dependencies which you previously installed globally (npm install -g <packageName>) and forgot about;
WebdriverIO (v4.8.0):
> browser.setValue('*[connectqa-mya="first-name"]',"t3st t3st t3st 1234test")
{ state: 'pending' }
> [13:27:12] COMMAND POST "/wd/hub/session/29096eb4bd851d6e3a49ad740c3c1ead/elements"
[13:27:12] DATA {"using":"css selector","value":"*[connectqa-mya=\"first-name\"]"}
[13:27:12] RESULT [{"ELEMENT":"0.8157706669622329-6"}]
[13:27:12] COMMAND POST "/wd/hub/session/29096eb4bd851d6e3a49ad740c3c1ead/element/0.8157706669622329-6/clear"
[13:27:12] DATA {}
[13:27:12] COMMAND POST "/wd/hub/session/29096eb4bd851d6e3a49ad740c3c1ead/element/0.8157706669622329-6/value"
[13:27:12] DATA {"value":["t","3","s","t"," ","t","3","s","t"," ","(13 more items)"],"text":"t3st t3st t3st 1234test"}
WebdriverIO (v4.7.1):
> browser.setValue('*[connectqa-mya="first-name"]',"t3st t3st test1234 ##$%^&*")
{ state: 'pending' }
> [13:38:25] COMMAND POST "/wd/hub/session/3b621c3d7a774872cf3a37d1bec17014/elements"
[13:38:25] DATA {"using":"css selector","value":"*[connectqa-mya=\"first-name\"]"}
[13:38:25] RESULT [{"ELEMENT":"0.42949459661053613-6"}]
[13:38:25] COMMAND POST "/wd/hub/session/3b621c3d7a774872cf3a37d1bec17014/element/0.42949459661053613-6/clear"
[13:38:25] DATA {}
[13:38:25] RESULT undefined
[13:38:25] COMMAND POST "/wd/hub/session/3b621c3d7a774872cf3a37d1bec17014/element/0.42949459661053613-6/value"
[13:38:25] DATA {"value":["t","3","s","t"," ","t","3","s","t"," ","(16 more items)"]}
As next-steps in the debugging process I would:
try to replicate the project with the same dependencies in a different folder/repo and see if it works;
for the above approach I would start with the latest versions of the packages you're using (e.g.: WebdriverIO wasn't up to date);
try to use .execute("$('<selector>').val('t3st t3st test12345');") and see if using JavaScript/JQuery would yield different results (if so, it would narrow down the problem: not form-validation, but probably chromedriver).
Let me know how it went, or if it helped. Cheers!

Related

Playwright Test execution report

After the test execution is there any way we can get a report of how many test passed and how many failed in playwright like in robot framework
The new built-in Playwright Test Runner has a number of reporter options. They are documented here:
https://playwright.dev/docs/test-reporters
There are currently 3 modes to output to the terminal ranging from a very verbose to a very terse output. They are list, line and dot.
There are a further 2 modes intended for output to file. They are json and junit. The former is self-explanatory, the latter produces JUnit-style xml output.
Finally there is the option to generate an HTML report.
The modes can be combined to control the terminal output and file output simultaneously.
You can configure many different reporters, that really depends on what you need, "like in robot framework" is quite broad since you can use different reporters with RF as well.
If you use Playwright with mocha, you can configure even more reporters:
.mocharc.json:
{
"reporter-options": [
"configFile=reporter-options.json"
]
}
reporter-options.json:
{
"reporterEnabled": "mocha-simple-html-reporter, spec, mocha-junit-reporter",
"mochaSimpleHtmlReporterReporterOptions": {
"output": "./Results/report.html"
},
"mochaJunitReporterReporterOptions": {
"mochaFile": "./Results/report-junit.xml"
}
}
Obviously you have to install dependencies:
package.json:
{
"devDependencies": {
"mocha": "~8.2.1",
"mocha-junit-reporter": "~2.0.0",
"mocha-multi-reporters": "~1.5.1",
"mocha-simple-html-reporter": "~1.1.0",
"playwright": "~1.10.0"
}
}
After this setup, html and junit reports will be available after test runs. Junit report should be enough so that it could be parsed in a pipeline and displayed on some dashboard.

Cannnot convert HTML code to PDF with vue-html2pdf

I have a project in vuejs and I have to use vue-html2pdf.
When I write text the in tag: <section>something</section>, my PDF is generated.
But when I write in tag: <section><p>something</p></section>, my browser is crashes.
Here my code in vuejs:
<vue-html2pdf
:show-layout="false"
:preview-modal="true"
:paginate-elements-by-height="10"
:filename="test"
:pdf-quality="2"
:pdf-format="size"
:ref="ref"
>
<section slot="pdf-content">
<section class="pdf-item">
<img :src=url>
</section>
</section>
</vue-html2pdf>
And my function to download PDF:
function generateReport() {
this.$refs.html2Pdf.generatePdf();
}
vue-html2pdf npm module does not work properly. Rather than you can try html2pdf module for convert html to pdf in vuejs.
Package link: https://www.npmjs.com/package/html2pdf.js/v/0.9.1
Codesandbox Example: https://codesandbox.io/s/xlnzq7y28q
Hope that, your problem will be solved. Thanks.
I just saw this, I am the developer of vue-html2pdf, and I tested your code on version 1.3.6, it worked perfectly on Chrome Version 81.0.4044.138, Microsoft Edge 44.18362.449.0 and Firefox 76.0.1.
you also have a typo on <img :src=url> it should be <img :src="url">
and if you can, can you please provide the values of the variables test, size, and ref, you assigned to the props.
and the prop :paginate-elements-by-height="10" I think the value should be higher, try 1300.
After losing my day I found the problem !
Here 2 sources of error :
-If you use a "component" inside the "vue-html2pdf", the page break couldn't work.
To solve this problem, use "vue-fragment" library <3
-If you use a too small value for "paginate-elements-by-height" attribute, the "vue-html2pdf will bug and then you can just kill the process. By default it's 1300 or 1400, try with 1600 or more and your problem will solved.
fixed this problem: Impossible to convert html code to pdf with vue-html2pdf
the first of all i have set packages in the such following sequence
1. npm i jspdf#1.5.2
2. npm i html2pdf.js#0.9.1
3. npm i vue-html2pdf#1.8.0
On time the passing some steps to create pdf file i got mistake
`TypeError: str.charAt(...) is not a function`.
or on another configuration for vue-html2pdf i am getting the console messages:
- Dom Has Rendered
- 0ms html2canvas: html2canvas $npm_package_version
- 926ms html2canvas: Document cloned, using computed rendering
- 926ms html2canvas: Starting node parsing
- 947ms html2canvas: Finished parsing node tree
- 948ms html2canvas: Finished loading 0 images Array(0)
- 949ms html2canvas: Starting renderer
- 950ms html2canvas: Canvas renderer initialized (816x18 at 312,63) with scale 2
- 959ms html2canvas: Render completed
but pdf file no created
I fixed this problem:
when i looked at "node_modules\html2pdf.js\package.json"
and i have seen
"dependencies": {
"es6-promise": "^4.2.5",
"html2canvas": "^1.0.0-alpha.12",
"jspdf": "^1.4.1"
}
then from "myproject\package.json" -
I have replaced
"dependencies": {
from "jspdf: ^1.5.2" to "jspdf: ^1.4.1"
so need to set
1. npm i jspdf#1.4.1
2. npm i html2pdf.js#0.9.1
3. npm i vue-html2pdf#1.8.0
so you should look at *jspdf version* into "node_modules\html2pdf.js\package.json"

Cannot add property _monthsRegex, object is not extensible momentJs

my moment package version
"moment": "^2.21.0",
"moment-timezone": "^0.5.23"
var temp = 'January 9th 2018';
console.log(moment(temp, 'MMMM Do YYYY')); // this throws error
I don't know how to solve it. When i run it within node project with same package version, It works. But when i run it within react native, it throws this error.
https://i.stack.imgur.com/kRgFi.png

Downloading entire NPM package list

This question is NPM specific.
Few years ago I wrote a tool named qnp that downloads entire list of npm packages and then executes local queries very fast, like 0.2 second per query. This allows to perform a very interesting study of the modern programming world, filtering by author names, descriptions, tags, etc, doing hundreds of queries, inspecting results, analyzing, having ideas, doing more queries. An official client is good, but does not allow you to do very fast queries at the speed of thought. Here is my question:
About a year ago the location of the registry metadata DB of NPM was abandoned, now it returns an empty file. How can I download/fetch the entire list of metadata now? I need at least those fields: title/author/description/keywords/date. Optionally downloads count, dependencies list, version.
Here is the code that was working previously:
var request = http.get({
host: 'registry.npmjs.org',
path: '/-/all/static/all.json',
headers: {
'Accept-Encoding': 'gzip, deflate'
}
}, function (a,b,c) {
var done = 0 ; var all = parseInt(a.headers['content-length'])
a.on('data', function (a,b,c) {
done += a.length
process.stdout.write( '\r' + (done / (all/100)).toFixed(2)+'% ' )
})
console.log('download started')
a.pipe(S)
S.on('finish', function (a,b,c) {
console.log('download complete')
S.close(f)
})
})
Since this post came up near the top when I searched for the answer, let me point out two packages that might be helpful for people landing on this old question:
https://github.com/nice-registry/all-the-package-names
https://github.com/bconnorwhite/all-package-names
Using the first one, I downloaded a list with 2.247.694 entries by using
pnpx all-the-package-names > ~/temp/all-the-package-names.txt
where pnpx is pnpm's equivalent to npx, the npm CLI runner (the latter installed with NodeJS).

Why does "npm search" provide incomplete results?

I've noticed, that using the npm search command does not guarantee complete results. Here is an example:
$npm search jasmine
does not list the jasmine-diff, jasmine-diff-reporter packages, while
$npm search jasmine diff
does.
I've read the doc, and there is no mention of any incompleteness, indeed it states
npm search performs a … search through package metadata for all files in the registry
I think, this somehow implies, that search should be consistent and complete. As one can see the jasmine-diff-reporter package does have the term jasmine in its keywords:
And it doesn't matter, that there is no word jasmine in the description section, since other packages like jasmine-diff have that word and are still missing in the $npm search jasmine output.
So could anyone explain this behavior somehow and/or suggest a workaround (except to use Google or something like that)?
The problem is the new "fast endpoint search" for the "npm search" that was implemented in the https://github.com/npm/npm/commit/e3229324d507fda10ea9e94fd4de8a4ae5025c75. I have registered a bug now: https://github.com/npm/cli/issues/1211.
I investigated npm scripts and found that the old search used the URL https://myNpmServer.com/repository/myNpmRegistry/-/all to get the package information while the new search uses https://myNpmServer.com/repository/myNpmRegistry/-/v1/search?text=%2F.*%2F&size=20. This value "20" is hardcoded, but you can change it with the --searchlimit=N parameter for the "npm search" and it is the simpliest workaround.
The only problem is that you never know how the search results are big. There is no value which means "infinity" (I tried to pass -1 and it did not work). If you really need the full search you can either refuse of "npm search" and parse directly the JSON output of the https://myNpmServer.com/repository/myNpmRegistry/-/all or you can hack the file <NodeInstallationDir>/lib/node_modules/npm/lib/search.js and add your own parameter --oldsearch:
if (npm.config.get('oldsearch')) {
allPackageSearch(searchOpts).on('data', function (pkg) {
entriesStream.write(pkg)
}).on('error', function (e) {
entriesStream.emit('error', e)
}).on('end', function () {
entriesStream.end()
})
} else {
esearch(searchOpts).on('data', function (pkg) {
entriesStream.write(pkg)
!esearchWritten && (esearchWritten = true)
}).on('error', function (e) {
if (esearchWritten) {
// If esearch errored after already starting output, we can't fall back.
return entriesStream.emit('error', e)
}
log.warn('search', 'fast search endpoint errored. Using old search.')
allPackageSearch(searchOpts).on('data', function (pkg) {
entriesStream.write(pkg)
}).on('error', function (e) {
entriesStream.emit('error', e)
}).on('end', function () {
entriesStream.end()
})
}).on('end', function () {
entriesStream.end()
})
After that you can say "npm search --oldsearch --registry ... '/regexp/'" and it must display really all packages.
ADDITIONAL NOTE (nice to know it):
Please be aware that during manipulating with .js scripts inside Node installation (adding there your printouts etc.) you can achieve an error message
npm ERR! invalid value written to input stream
After that something gets broken and "npm search" stops working at all or displays really few output. In order to repair this just keep adding other printouts until it fails again with the abovementioned message. Then the next run (only once) you see these messages:
npm WARN all-package-metadata cached-entry-stream Empty or invalid stream
npm WARN Failed to read search cache. Rebuilding
npm WARN Building the local index for the first time, please be patient
and it returns to proper state again. I did not investigate furhter why this happens and did not find a way to force invalidating this search cache.
I hope my investigations can become helpful for somebody.