HeadlessExperimental in Puppeteer - google-chrome-devtools

I'm using Puppeteer and I'd like to access the HeadlessExperimental domain.
I can enable the domain, but if I try calling beginFrame, I get this error message:
content-generator-api-0 | Error: Protocol error (HeadlessExperimental.beginFrame):
Command is only supported if BeginFrameControl is enabled.
Here is the code I'm running
const browser = await puppeteer.launch(...)
const page = await browser.newPage()
await page.goto(url)
const cdp = await page.target().createCDPSession()
await cdp.send('HeadlessExperimental.enable')
const frameData = await cdp.send('HeadlessExperimental.beginFrame', {screenshot: {}})
I have the following chromium flags set, as suggested in "Rendering in Headless Chrome"
'--enable-surface-synchronization',
'--run-all-compositor-stages-before-draw',
'--disable-threaded-animation',
'--disable-threaded-scrolling',
'--disable-checker-imaging',
Judging by a description found in the chromium.org forum, my guess is that I'll need to modify the Puppeteer lib to support creating targets with BeginFrameControl.
Currently, the BeginFrameControl is only supported in headless mode
and can only be enabled at target creation time.
Also, the stable release of Puppeteer is running chromium revision 594312, but it looks like the HeadlessExperimental wasn't patched in until 612061, which isn't included in any of the current chromium releases

Add --enable-begin-frame-control switch to chrome launch parameters

Related

How can i run webdriver from my assets folder using webdriver package?(Windows)

I tried these codes but none of them worked. I don't want to use environment variables,i want to use local file.
Uri fpath= Uri.file('assets/msedgedriver.exe',);
await launchUrl(fpath);
WebDriver driver = await createDriver(desired: Capabilities.chrome,uri: Uri.parse('assets/msedgedriver.exe'));
driver.driver.get('https://www.google.com');

How can I know the base url used in a running test in protractor?

I'm trying to do navigation test in protractor and don't see any consitency with the baseUrl in the config and the url used in the test.
protractor.conf.js
exports.config = {
baseUrl: 'http://localhost:4200/'
}
navbar.e2e-spec.ts
import { NavbarPage } from './navbar.po';
import * as protractor from './../protractor.conf.js';
describe('navbar', () => {
let navbar: NavbarPage;
const baseUrl = protractor.config.baseUrl;
beforeEach(() => {
navbar = new NavbarPage();
browser.get('/');
});
it(`should see showcase nav item, be able to (click) it,
and expect to be navigated to showcase page`, () => {
const anchorShowcase = navbar.anchorShowcase;
expect(anchorShowcase.isDisplayed()).toBe(true);
anchorShowcase.click();
browser.waitForAngular();
expect(browser.getCurrentUrl()).toBe(baseUrl + '/showcase');
});
});
Although when I run the e2e test it uses a different port:
** NG Live Development Server is listening on localhost:49154, open your browser on http://localhost:49154/ **
Why is the test url set to port 49154. This apparently seems to be the default if you start a new angular-cli project: https://github.com/angular/angular-cli
How can I get control over the baseUrl / Or is http://localhost:49154/ safe to use for all my angular cli projects?
By default when you do ng e2e the command take --serve value as true. It means it will build and serve at that in a particular URL. Not the baseUrl you passed in protractor.conf.js
that is why, you are getting a random URL served when testing you app like http://localhost:49154/
Now as you don't want build during test and want to test existing build (URL) like http://localhost:4200/ you need to pass --no-serve in your command line and it will pick baseUrl from the protractor.conf.js
you can also pass baseUrl in the command line like below. note that this not baseUrl but --base-href=
ng e2e --no-serve --base-href=https://someurl.com:8080
When running Angular CLI's ng e2e command, it states in the wiki that the default port will be random, as seen here:
https://github.com/angular/angular-cli/wiki/e2e
Under the serve submenu.
The e2e command can take in all the same arguments as serve so to keep the port the same just pass in --port my-port-number to the ng e2e command.
As far as that port being safe to use, I wouldn't use it, it is just a random port after all. I would stick to the default unless you have a use-case for changing it. The port is mainly relevant for the dev server, not so much for where ever the production code runs.
Aniruddha Das's solution doesn't work anymore as this option isn't there from Angular CLI 6.x version, you can try following -
ng e2e --dev-server-target=
please see following reference

gcloud deploy function error code 3

I'm doing the tutorial of basic fulfillment and conversation setup of api.ai tutorial to make a bot for facebook messenger, and when I try to deploy the function with the command:
gcloud beta functions deploy testBot --stage-bucket testbot-e9bc4.appspot.com --trigger-http
(where 'testBot' is the name of the project and 'testbot-e9bc4.appspot.com' is the bucket_name, I thought..)
It return the following error message:
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Source code size exceeds the limit
I've searched but not found any answer, I don't know where is the error.
this is the JS file that appear in the tutorial:
/
HTTP Cloud Function.
#param {Object} req Cloud Function request context.
#param {Object} res Cloud Function response context.
*/
exports.helloHttp = function helloHttp (req, res) {
response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working
res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
res.send(JSON.stringify({ "speech": response, "displayText": response
//"speech" is the spoken version of the response, "displayText" is the visual version
}));
};
Make sure you are in the correct directory where your go code resides before executing gcloud beta functions deploy testBot --stage-bucket testbot-e9bc4.appspot.com --trigger-http command.
I was working in the express project. In my case, I mistakenly installed the #google/storage package in devDependencies instead of dependencies. I unable to notice as I tested the project in debug mode using mocha. So in debug, it is able to find that package in devDependencies but on deploy function, it tries to find in dependencies in package.json but unable to find there.
Open command prompt at the location where index.js was created and run the above gcloud command.

Parameters were incorrect when running Selenium?

I'm testing my app on mac with real ios device. When i run the scripts it says following error in Eclipse IDE,
org.openqa.selenium.SessionNotCreatedException: Unable to create new
remote session. desired capabilities = Capabilities
[{app=/Users//Downloads/XXX.ipa,
platformVersion=10.2.1, platformName=iOS, deviceName=Mr.x'S iPod touch,
UDID=*****}], required capabilities =
Capabilities [{}]
Then i checked the logs in appium it shows,
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were
incorrect. We wanted {"required":["desiredCapabilities"],"optional":
["requiredCapabilities","sessionId","id"]} and you sent [
"desiredCapabilities" , "requiredCapabilities", "capabilities",
"alwaysMatch","firstMatch"]
What should i do to fix this, Can anyone help me to resolve this.
Yes, you need xcode to access iOS native app.
Desired capabilities to be used:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "iOS");
capabilities.setCapability("platformVersion", "9.3");
capabilities.setCapability("deviceOrientation", "portrait");
capabilities.setCapability("browserName", "Safari");
capabilities.setCapability("autoWebview", "true");
capabilities.setCapability("automationName", "XCUITest");
capabilities.setCapability("deviceName", "iphone");
capabilities.setCapability("autoAcceptAlerts",true);
capabilities.setCapability("udid", UDID);
capabilities.setCapability("xcodeConfigFile", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/Config.xcconfig");
capabilities.setCapability("realDeviceLogger","/usr/local/lib/node_modules/deviceconsole");

Node.js 6.x async/await in required libs with Babel

For some reason I should use Node.js 6.x (actually 6.10.0) and I'm trying to run koa2 with Babel as described here. My code looks like this
const Koa = require('koa');
var app = new Koa();
// --- middlewares ---
async function a(){await 1} // okay here!
console.log(a());
const serve = require('koa-static');
app.use(serve('./web'));
app.use(require('koa-cookie').default());
app.use(require('koa-bodyparser')()); // fails here
And I'm getting error
D:\Project\node_modules\koa-bodyparser\index.js:72
return async function bodyParser(ctx, next) {
^^^^^^^^
SyntaxError: Unexpected token function
Running node with nodemon index.js --exec babel-node on Windows
Works perfect on Node 7.x, but I need to use 6 unfortunately :(
async and await are not yet supported in Node.js 6.x. They are ES2017 features and are only supported in Node 7.6+.
The Babel preset you're using is obviously not working - make sure you are using the correct babel preset (ES2017) as per the instructions on the Babel site.