I'm running a headless chrome to take screenshots of tweets via the oEmbed API.
Downloading the tweets and creating the HTML works fine, but the embedded JS does not run, which causes the tweets to be unstyled in the screenshot.
When I fetch the created HTML file and open it in my Firefox, the JS is loaded, executed and styles the tweet perfectly.
Is this a problem with headless chrome, twitter itself or something else?
My CLI command looks like this:
google-chrome -headless -screenshot=' + filename_image + ' ' + msg.filename + ' -force-device-scale-factor=2 -virtual-time-budget=20000 -window-size=516,3000 --disable-gpu
This is from the node-red script which prepares the CLI command which is then passed to the bash via an "exec"-node.
Edit #1: To make it clear: The screenshot works in general, but the result is unstyled, as no external script is loaded and executed.
I've also tried to disable ufw to check whether it's a problem with the firewall. It's not. The problem persists, even with disabled firewall.
Edit #2: I added the --disable-gpu flag to get rid of this error message, which was also written to the console. Sadly that didn't change anything about the end-result.
Edit #3: Back on this. Tried running the same exact command through a PHP script. Everything works fine, tweets are styled perfectly. Doesn't make this any less strange.
Related
Tried below code to click ctrl+J but did not work for chrome browser.
#browser.driver.action.key_down(:control).send_keys("j").key_up(:control).perform
Also tried
#browser.driver.action.send_keys(:control,"J").perform
I read in one blog, above code would work for Firefox browser but not for Chrome.
First off,
The way you send control+j is wrong. The way to send the control+j is,you have to give control+k inside the [] like [:control,"j]
b.send_keys([:control,"j"])
Second off,
it's not possible to send the [:control,"j] via chromedriver because of the following issue
https://bugs.chromium.org/p/chromedriver/issues/detail?id=903
The exact answer lies here
This is a limitation in the way we simulate keyboard input in ChromeDriver. Keys get sent directly to the render process, bypassing the browser process. So any keyboard shortcut handlers in the browser process will not be invoked by sendKeys().
I got a task to update a URL in a test (using Selenium, Java and Chromedriver) to a new URL. The page is the same, just at a new location. This test worked fine with the old URL.
I brought up an instance of Chrome and verified I could access the URL.
Then I changed the URL, committed to git, and ran on our Jenkins machine and it failed. The screenshot said "This site can’t be reached". I told a co-worker that I think the URL must be wrong (though it worked on my desktop without Selenium). He tried it and it loaded fine. I tried it again from a regular Chrome window and it loaded fine. I tried from Eclipse using Selenium and I got the message about the site could not be accessed.
So I ran Eclipse, stopped it right when Chrome came up but hadn't loaded a URL yet. I manually entered the URL (from copy/paste) and got "This site cannot be accessed). Then I brought up a regular Chrome window and pasted the URL in and it loaded fine.
I decided to look for differences. So in my regular Chrome window it was "Version 77.0.3865.120 (Official Build) (64-bit)". I did the same on the version running under Chromedriver and got "Version 77.0.3865.120 (Official Build) (64-bit)". So the same.
I did a search for the latest Chromedriver. It said for version 77 to please use 77.0.3865.40. This was not what I was using. So I downloaded the correct version and thought "surely this will fix it". I verified it was 77.0.3865.40 coming up. But, as you guessed it, I got the same problem after updating to the most compatible Chromedriver.
Some searches said that basically nothing would be able to tell, but there was one property that Chromedriver inserts. I don't know whether this would be enough to block a session using Chromedriver?
The only thing I can think of is that we have iBoss and possibly iBoss is blocking it? Either that or somehow the site is blocking it.
I would like to share the URL with you but I do not know whether that would be violating company policy. If I get permission, I will share the URLs.
by the way, the error is "ERR TUNNEL CONNECTION FAILED"
Got some internal help to help fix some settings
I have a file upload control in my UI marked with webkitdirectory. When I upload a folder in the following way, running in non-headless mode, it works:
find('.directory-upload', visible: false).set(Rails.root + "test/data/directory_to_upload")
However, when I run headless (with the :headless_chromium driver) it fails silently, i.e. the code runs but the directory isn't actually selected in the control (so the ensuing form validation fails).
Are there differences in supported HTML between headless and non-headless that could explain this?
You've run into a known bug in headless Chrome - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary - nothing your can really do about it.
We have automated 5 test cases and ran locally and seems to be worked fine. When the same code base is running on CI server(linux box against firefox browser), It failed to execute. However I used xming to see the GUI execution part and observed the browser is keep on loading and not displayed any web element to perform action. I just cross check with whether its proxy issue, and handled through code as below: (Due to security issue I can't able to share proxy details, but I pinged It returned proper response.)
Sample Code(created firefox profile):
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "someproxy.com");
profile.setPreference("network.proxy.http_port", 8090);
//Other dependencies like "No Proxy for" is added in firefox.
profile.setPreference("network.proxy.no_proxies_on","localhost, 127.1.1.1, prt-www.xxx.com, ti.xxx.com, s3, xxx.com" );
DesiredCapabilities desired = DesiredCapabilities.firefox();
desired.setCapability(FirefoxDriver.PROFILE, profile);
I really don't understand the root cause for this issue. Can somebody tell me what would be the root cause for this issue?
I check the firewall in that box , and It has been stopped.
I have this weird issue in my django application. I am using the admin interface. When I try to load the change page it doesn't render completely and when i see in logs it says:
**uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 248]
IOError: write error**
The page has been working fine before and suddenly this started happening. And also the behavior is inconsistent. If I reload the page multiple times, few times it renders correctly. This issue is happening in production environment and I am not able to replicate it on my local. The production server is using uwsgi 1.9.10 with nginx and django 1.5. Also I am writing custom HTML on page and there is an inline table also on the same page.
Please let me know if anyone knows why it is happening...
that error means the client (browser) disconnected before getting the full response. Check your webserver logs, maybe you hit a timeout