PhantomJs rendering - phantomjs

Is there any limit to the number of characters for the file name to get it render from phantomJs?
var page = require('webpage').create();
page.open('http://github.com/', function() {
window.setTimeout(function(){
var filename = encodeURI('The code shown here is also available in various examples included with PhantomJS. You are also recommended to explore the use of PhantomJS for page automation, network monitoring, screen capture, and headless testing The code shown here is also available in various examples included with PhantomJS. You are also recommended to explore the use of PhantomJS for page automation, network monitoring, screen capture, and headless testing');
console.log('filename: ' + filename);
page.render(filename + ".png");
phantom.exit();}, 100);
});
This file is not getting render through phantomJs.
Can someone please help here?

I don't think it has anything to do with PhantomJS, but basically with your OS. There is a size limit for the file path name in every OS.
According to the naming convention in Windos OS -
In the Windows API (with some exceptions discussed in the following
paragraphs), the maximum length for a path is MAX_PATH, which is
defined as 260 characters. A local path is structured in the following
order: drive letter, colon, backslash, name components separated by
backslashes, and a terminating null character. For example, the
maximum path on drive D is "D:\some 256-character path string"
where "" represents the invisible terminating null character for
the current system codepage. (The characters < > are used here for
visual clarity and cannot be part of a valid path string.)

Related

Rendition report is not used when switching resolution on avplayer (safari 16.3)

I'm developing a LL-HLS feature.
When playing the LL-HLS that I developed in Safari, the EXT-X-RENDITION-REPORT tag does not seem to work when the resoution is changed by ABR.
When changing the resolution, the following request is made.
Request without _HLS_msn and _HLS_part query strings when calling chunklist.m3u8 of different resolutions.
Request including _HLS_msn and _HLS_part query strings after requesting chunklist.m3u8 of 1).
In a hls.js, when changing to a different resolution, it was confiremed that _HLS_msn and _HLS_part query strings were included immediately.
OS: macOS (Ventura 13.2.1)
Browser: Safari 16.3
Chunklist.m3u8
EXT-X-SKIP tag is not used
URL: http://10.60.83.51/cvpr0502/onair_llhls_test0001/chunklist_vfrag2500.stream.m3u8
This URL does not play as s sample.
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK=3.000000
#EXT-X-PART-INF:PART-TARGET=1.000000
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:4
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-DATERANGE:ID="nmss-daterange",START-DATE="2023-02-20T08:20:00.474Z"
#EXT-X-MAP:URI="vfrag2500.stream_0_0_0.m4s?type=hls&filetype=.m4s"
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:13.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_1994603194_1676881213474_13_0_4_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_1994603194_1676881213474_13_0_4_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_1994603194_1676881213474_13_0_4_2.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXTINF:3.000000,
vfrag2500.stream_1994603194_1676881213474_13_0_4.m4v?type=hls&bitrate=287035&filetype=.m4v
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:16.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3207465476_1676881216474_16_0_5_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3207465476_1676881216474_16_0_5_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3207465476_1676881216474_16_0_5_2.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXTINF:3.000000,
vfrag2500.stream_3207465476_1676881216474_16_0_5.m4v?type=hls&bitrate=345122&filetype=.m4v
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:19.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3408866808_1676881219474_19_0_6_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3408866808_1676881219474_19_0_6_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_3408866808_1676881219474_19_0_6_2.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXTINF:3.000000,
vfrag2500.stream_3408866808_1676881219474_19_0_6.m4v?type=hls&bitrate=277635&filetype=.m4v
#EXT-X-PROGRAM-DATE-TIME:2023-02-20T08:20:22.474Z
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_562750089_1676881222474_22_0_7_0.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PART:DURATION=1.000000,URI="vfrag2500.stream_562750089_1676881222474_22_0_7_1.m4v?type=hls&mode=cmaf&filetype=.m4v",INDEPENDENT=YES
#EXT-X-PRELOAD-HINT:TYPE=PART,URI="vfrag2500.stream_562750089_1676881222474_22_0_7_2.m4v?type=hls&mode=cmaf&filetype=.m4v"
#EXT-X-RENDITION-REPORT:URI="chunklist_vfrag1500.stream.m3u8",LAST-MSN=7,LAST-PART=1
#EXT-X-RENDITION-REPORT:URI="chunklist_vfrag400.stream.m3u8",LAST-MSN=7,LAST-PART=1
#EXT-X-RENDITION-REPORT:URI="chunklist_vfrag100.stream.m3u8",LAST-MSN=7,LAST-PART=1
Network in safari
First chunklist.m3u8 request with different resoltuion
_HLS_msn and _HLS_part query strings not found in URL
enter image description here
Second chunklist.m3u8 request
_HLS_msn=7&_HLS_part=1 query strings included in URL
enter image description here
I tried putting paths in various patterns such as absolute paths and relative paths in the URL property of the EXT-X-RENDITION-REPORT tag, but is didn't work.
Is this the behavior of the EXT-X-RENDITION-REPORT tag? If not, I would be grateful if you could let me know what part needs to be corrected.

Issues with video path

TestCafe doesn't recognize ${TEST} for video path.
I'm trying to implement test recording for failed tests in order to see how we could replicate the appeared problem, but the video path isn't recognized even though a similar path pattern works for screenshots.
According to the documentation, this should work but the following warning is displayed:
Warnings (1):
The "${TEST}" path pattern placeholder cannot be applied to the recorded video.
The placeholder was replaced with an empty string.
I created TestRunner.js as shown in https://devexpress.github.io/testcafe/documentation/using-testcafe/programming-interface/runner.html. Then I added
if(runnerOptions.takeVideo === true && runInParallel === 1) {
runner.video(reports.videoPath, {
singleFile: true,
failedOnly: true,
pathPattern: store + '-' + env + '/${TEST}/${DATE}_${TIME}/${USERAGENT}'
})
}
return runner
.src(tests)
.browsers(config.browsers)
.screenshots(reports.screenshotPath, runnerOptions.takeScreenshots,
store + '-' + env + '/${TEST}/${DATE}_${TIME}/${RUN_ID}/${USERAGENT}/step-${FILE_INDEX}')
.concurrency(runInParallel)
.run(runnerOptions.run);
As I said screenshots work fine, but videos don't.
According to this GitHub issue, specifying singleFile: true is the cause. When saving all the failed tests into one recording, the path pattern can't use a single test or fixture identifier to name the file.
The following pattern placeholders resolve to an empty string with a single file:
${TEST_ID}
${TEST_INDEX}
${FIXTURE}
${TEST}
${TEST_ID}
The documentation for the path patterns does mention this restriction for single files, but only in reference to ${TEST_ID} and not the other placeholders.
I've checked the scenario and it works without any "path pattern" issues under Windows 10:
testcafe chrome test.js --video artifacts/videos --video-options pathPattern=${TEST}.mp4
Would you please clarify how you specified the pathPattern video option? In addition, please provide your environment details.

Google Drive - use WebViewLink vs thumbnailLink

I'm using the Google Drive API where I can gain access to 2 pieces of data that I need to display a jpg file oin my program. WebViewLink is the "large" size image while thumbnailLink is the "thumb" smaller size of the same image.
I'm having an issue with downloading the WebViewLink that I do not have with the thumbnailLink. Part of my code calls either exif_imagetype($filename) or getimagesize($filename) so I can retrieve the type, height & width etc for the $filename. This is successful for the thumbnailView but not the WebViewLink...
code snippet...
$WebViewLink = "https://drive.google.com/a/treering.com/file/d/blablabla";
$type = exif_imagetype($WebViewLink);
--- results in the error
"PHP Warning: exif_imagetype(): stream does not support seeking..."
where as...
$thumbnailLink = "https://lh6.googleusercontent.com/blablabla";
$type = exif_imagetype($thumbnailLink);
--- successful
where $type = 2 // a .jpg file
Not sure what I need to do to gain a usable WebViewLink... maybe use the "export" function to copy to a file on my server that is accessible, then use that exported file for the functions that fail above?
Thanks for any help.
John
I think you are using the wrong property to get the image of the file.
WebViewLink
A link for opening the file in a relevant Google editor or viewer in a browser.
thumbnailLink
A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours.
You can try using the iconLink():
A static, unauthenticated link to the file's icon.
Sample image of thumbnailLink:
Sample image of a iconLink:
It will still show relevant image about the file.
Hope it helps!

Balanced Payments doesn't seem to work with Phonegap

We are not able to call balanced.card.create from a Phonegap application. This is reproduced in a stock Phonegap application here: https://github.com/kevg/phonegap-balanced. Full details are in the README.md on github, but the basic summary is:
For those not familiar with phonegap, the main page that loads is
index.html. This initializes phonegap in index.js. When the device is
ready, we will show a hidden DIV with a button named "Execute
Balanced." When you click this button, app.executeBalanced in index.js
will be called which prompts for the balanced marketplace URI, loads
balanced.js with $.getScript, and then calls balanced.card.create with
a test credit card.
The expected result is that callbackHandler is called or an exception
is caught. Instead, it seems the execution of the Javascript thread
disappears into balanced.card.create, never to return and without any
error.
Alrighty, I found the bug in balanced.js. So, in Phonegap, window.location.href returns something like file:///.../index.html. Balanced.js creates an iframe to something like https://js.balancedpayments.com/proxy#file
var src = proxy + "#" + encodeURIComponent(window.location.href);
https://github.com/balanced/balanced-js/blob/master/src/utils.js#L48
In the script returned in proxy.html (which I can't find on github), it does:
c.parentURL=decodeURIComponent(
window.location.hash.replace(/^#/,"")
).replace(/#.*$/,"")
c.parentDomain=c.parentURL.replace(/([^:]+:\/\/[^\/]+).*/,"$1")
The regex doesn't match because file: has three slashes. Now, at first, I thought I could just convert the regex to:
/([^:]+:\/+[^\/]+).*/
However, then there's another problem, because balanced does a security origin check on the match:
if (d.origin.toLowerCase() !== c.toLowerCase()) return !1;
However, the regex returns file:///firstcomponent, whereas event.origin does not include a host name for the file scheme, so these won't match even with a fixed regex.
I can't change anything in the script returned in the proxy response because if I load that from a domain other than balancedpayments.com, then the AJAX POST fails (return code 0 with a blank body). Therefore, the only thing I can control is the hash passed to the iframe.
However, since this regex is a replace, we can simply pass exactly what we know we need (we don't care that the regex is a no-op).
Therefore, the solution is to change L48 above to:
var src = proxy + "#" + encodeURIComponent("file://");
This works.

Textbox Restrictions(Special chars/Numeric etc) not working for selenium automated test execution

I am testing a web application where certain text fields have restrictions based on requirements (eg.Amount textfield disallows alphabets and special characters & Name textfield disallows Numeric and special characters.), So while trying manually in a browser the restrictions work fine. But while automating the same testcase such textfields accept all data(eg. alphabets(lowercase and upper case),digits,special characters.)...Means in automation no restricton works at all..I am writing automated tests using Selenium in Eclipse(testNG framework) and using SeleniumRC to run tests.
I would suggest to use RegExps for verifying strings format.
e.g. my veryfying of build version format
#Test
public void buildVersionFormatVerify() throws IOException {
String buildVersion = findElementByCssSelector("home.buildversion.label").getText().trim();
String extractedVer;
extractedVer = buildVersion.substring(buildVersion.indexOf(':')+1,buildVersion.length()).trim();
Assert.assertTrue("build version does not match regexp",extractedVer.matches("\\d.\\d\\s.\\s\\d{2}"));
}
another approach can be the following:
you enter a certain string which does not satisfy input format accordingly to functional spec. Then you can trigger somhow that input was accepted (no error messages appears or validator has not handled inproper input) and you can block the 'accepted input' not following to functional spec with assert
e.g.
Assert.assertFalse("improper input format",isElementPresent(By.xpath(...xpath of the error message...)));
IMHO, it is my vision of solution to this issue.