phantomjs japanese/chinese websites - phantomjs

I am having some issues with phantomjs when it comes to chinese/japanese websites. At first it thought the problem was with the screen capture. But it turns out, it's also a problem with a simple page.open. (see below)
var page = require('webpage').create();
page.open('http://www.qq.com', function(status) {
console.log(status);
});
The execution goes on indefinitely, whereas for other websites such as facebook.com it returns success without issues.
Could any one indicate why this could be happening?
When i would try and use the capture feature using render, I would get messages similar to the below:
baidu.com
TypeError: null is not a constructor (evaluating 'g.m("ytbin.www.pageframe.setup")()')
https://s.ytimg.com/yts/jsbin/www-en_US-vflpLdWUR/base.js:144 in c
https://s.ytimg.com/yts/jsbin/spf-vflTmp1fT/spf.js:14
:0 in forEach
https://s.ytimg.com/yts/jsbin/spf-vflTmp1fT/spf.js:7 in u
https://s.ytimg.com/yts/jsbin/spf-vflTmp1fT/spf.js:14 in Ha
https://s.ytimg.com/yts/jsbin/spf-vflTmp1fT/spf.js:17 in Ua
https://s.ytimg.com/yts/jsbin/spf-vflTmp1fT/spf.js:7
and
TypeError: undefined is not an object (evaluating 'toConfig.oid')
http://ra.gtimg.com/web/crystal/v2.6Beta05Build050/crystal-min.js:178 in callback
http://ra.gtimg.com/web/crystal/v2.6Beta05Build050/crystal-min.js:182
I would greatly appreciate if someone could assist.
(further info:
Tried both on Windows 10 and Mac OSX El Capitan
Also tried compiling phantomjs from source, but encountered issues on Mac OSX El Captian, for which there are no fixes as yet)
Thanks

Related

WebdriverIO: Execution context is not available in detached frame

I'm trying to automate a flow that I've been doing at least once a day for the past 3 years. It's an unnecessarily convoluted process that is taking time out of my day. It's an internal proprietary system, so I can't give you any details about it, but suffice to say that I cannot change it. I have to try to automate it the way it is, and I'm stuck with the following error:
Execution context is not available in detached frame "https://..." (are you trying to evaluate?)
I'm using WebdriverIO with the default configuration, which uses Puppeteer internally. When I googled the error, I got a suggestion to add the following flags:
'--disable-web-security', '--disable-features=IsolateOrigins,site-per-process'
I did that, but it didn't help:
remote({
logLevel: 'trace',
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--disable-web-security', '--disable-features=IsolateOrigins,site-per-process']
}
}
})
I want to try it out in the REPL to do some more debugging, but I haven't figured out how to add those args when launching the REPL:
npx wdio repl chrome
Everything I've tried so far has failed. If someone knows how to do it, please let me know.
I don't do web automation normally and I chose WebdriverIO, since I have used it in the past for mobile automation. I'm wondering if this is a Puppeteer specific issue and if it would work in Selenium, but I'm not quite sure how to set that up. Puppeteer was just working out of the box.
Any guidance on how to get past this error would be greatly appreciated.
Turns out it was pretty simple:
browser.switchToFrame($('#iFrame'))
// Doing stuff inside the frame that causes the next page to show.
// Now that iFrame is gone and I have to switch out of it, to continue:
browser.switchToParentFrame()
// After the above call the execution context is not in a detached frame anymore.

Changing window size with Selenium used with a Chromium based browser

I am using Selenium 2.35.0 to test a Chromium based browser. I am using Chrome driver version 2.43.600233 and set my application name to Chrome and version to 2.43.600233 as recommended in https://forum.qt.io/topic/96202/unrecognized-chrome-version-when-using-selenium-python-bindings-and-chromedriver
"I had the same problem, and a way to hack it is to set your QT applicationName and applicationVersion to "Chrome" and "69.0.3497.128". "
Everything then worked fine. I only ran to an issue when I tried maximizing,minimizing, changing window size of my window using
driver.manage().window().maximize();
driver.manage().window().setSize(d);
I ran to this error
{"code":-32601,"message":"'Browser.getWindowForTarget' wasn't found"}.
When I searched for that error,I found this question
Сhromedriver: how to add support of Chromium-based browsers
The answers mentions
I warn you in advance that you should not use the window_size
parameter, since Chromium does not support it, otherwise we will
encounter an error:
[Facebook\WebDriver\Exception\UnknownServerException] unknown error:
unhandled inspector error:
{"code":-32601,"message":"'Browser.getWindowForTarget' wasn't found"}.
Is there any hack to get over that. I need to test my browser when I do any window resizing.
Thanks a lot in advance.
I can tell you that on all recent Chrome versions (going back years), with up-to-date Chromedriver, in C#, setting driver.Manage().Window.Size works fine for me. But, I'm unfamiliar with setting app names and versions like you're doing. Does it work if you don't call maximize() first?
I did the resizing using xdotool http://manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html.
In my java code I have this function
public void xdoWindowResize(String width,String height)
{
String title= driver.getTitle();
try{
ProcessBuilder pb = new ProcessBuilder("./resize.sh", title,width,height);
Process p = pb.start();
}
catch (Exception e) {System.out.println(e);}
}
and resize.sh
#!/bin/sh
my_id=$(xdotool search --name "$1")
xdotool windowsize $my_id $2 $3

Unable to get Gamepad events on Chromium Version 44.0.2383.0

I'm trying to get my gamepad events in chromium. Everything works perfectly fine on Chrome Version 44.0.2403.130 m with this code :
var gamepadList = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads : []);
But on the WebVR chromium version made by Brandon Jones, I can't get any feedback, the 'navigator.getGamepads()' function returns only an array of four undefined variables.
Is it not supported yet? Or do I need to do something specific?
Thanks for the help!
Seems to work for me using this test page:
http://www.html5rocks.com/en/tutorials/doodles/gamepad/gamepad-tester/tester.html
Keep in mind that, due to fingerprinting privacy concerns, you to press a "face" button on the controller before it is visible to the API.

Javascript split working incorrectly in IE

I have one page checkout. My OPC works fine with other browsers but I get a fatal error with IE. IE's Javascript console says Object doesn't support this property or method.. The method in question is var items = field_name.split(reg) from the file: order-address.tpl.
I have no idea what is causing the problem. Because of this error, I cannot login properly from one page checkout when using IE. It seems that there are a lot of people with the same problem. What's the issue?
This error is present in 1.4.9, 1.4.10, and 1.5.3.
SOLVED. It turns out the issue is not with coding but with settings of IE.
All I had to do was reset IE from Tools => internet options => advanced => reset (including personal settings)
That did it for me. Thank you altafhussain for trying to help me out.

chrome.extension.onMessage is undefined

I have a simple plugin that just does something like this:
chrome.extension.onMessage.addListener(function(msg, _, sendResponse) {
log("Got message from background page: " + msg);
});
unfortunately when my panel is loaded the following error is shown:
TypeError: Cannot call method 'addListener' of undefined
and according to my tests chrome.extension.onMessage is undefined
According to this page http://code.google.com/chrome/extensions/messaging.html I should be able to access this chrome API from my page so it has to be something small that I am missing here...
Please note methods chrome.extension.onRequest and chrome.extension.sendRequest, as originally suggested in this answer, are deprecated as of Chrome 33.
You should use
chrome.extension.onRequest
instead of
chrome.extension.onMessage
And in background page or any other extension scripts:
chrome.tabs.sendRequest
instead of
chrome.tabs.sendMessage
( the documentation is outdated... alert to google team ;) )
Just a side note: the Yandex browser (mostly oriented for Russians) which is also based on Chromium still (as of 11/10/2012, ver. 1.0) has the .*Request methods instead of .*Message. Many thanks to Ciprian Amariei for the tip, it saved me a lot of time!
PS: This should actually be a comment to Ciprian Amariei's answer but unfortunately I can't leave comments yet and I though this information could be very helpful to those who develop extensions for Yandex browser.
Make sure you're using the latest Google Chrome version. Older versions don't have the chrome.extension.onMessage API.