Nightwatch + phantomJS: how to get logs from console - phantomjs

I do the next test with nightwatch:
var page = browser.page.certificats();
page
.navigate()
.section.search
.waitForElementNotPresent('#loader', 1000);
.waitForElementPresent('#option', 2000)
On firefox and chrome, all work fine. With phantomJS, the test fails because it doesn't find the #option.
The #option element is build by some JS code.
I suspect a JS error but I can't get the JS error in console with phantomJS.
How can I get theses logs ?
Thanks.

Related

Element inaccessible via Cypress Test Runner that is accessible via a regular browser

Click here for image that compares the two different results returned for the same javascript command.
On the left is the image of the web page run inside Cypress Test Runner.
On the right is the image of the web page is a regular browser.
To produce the same result :
In standalone Chrome, load this url, open dev tools and then run the javascript command shown below.
document.querySelector('body#google-amp-body > amp-analytics:nth-child(3) > script')
Copy the following code into a spec file and run it inside Cypress Test Runner. Then open dev tools in the Test Runner window and run the same javascript command. You won't get anything back for this use case. See above screenshot to get a visual sense of what I mean.
If I try to perform cypress tests based on that element in Cypress I get nowhere because that element cannot be found inside Cypress.
If I access the same element via Python/Selenium code, it works fine.
describe('Gamespot Test', () => {
it('Tests for Video Page', () => {
const url = "https://gamespot.com/amp-videos/rainbow-six-extraction-final-preview/2300-6457072/"
cy.visit(url)
})
})

Selenium: Page JS not running, stuck in load

Running a scraper on a site and the js doesn't seem to be working. Stuck on "loading" on the page but the rest of the html is loading fine.
Screen shot of load.
https://i.stack.imgur.com/0WofB.png
from selenium import webdriver
bin_path = ''#path to local bin file for driver
driver = webdriver.Chrome(executable_path=bin_path,desired_capabilities={'javascriptEnabled': True})
driver.get(URL)
Not sure if I need to pull the name of each script and execute it one at a time?

TestCafe: Uncaught ReferenceError: pagespeed is not defined

New to TestCafe.
Expected
Given .js below, expected behavior when running testcafe chrome this.js is to click on the header logo.
Actual
Uncaught ReferenceError: pagespeed is not defined (at the click below).
On our prod site, this error doesn't happen so most likely some configuration (possibly my version of Apache?) but I wanted to make sure there weren't any TestCafe specific issues. Followed installation using the standard docs (npm)
Thanks in advance!
import { Selector } from 'testcafe';
fixture `A set of examples that illustrate how to use Little Passports`
.page `https://xxx.xxdev.us/`;
test('My Company', async t => {
await t.
click('.header-logo');
});
I think I'll currently get around this by adding -e, but I'll keep this open just in case there's something else to consider...
By default, a test fails when there is a JavaScript error on page. The "-e (--skip-js-errors)" parameter allows running tests by skipping this JS error.
To check if there are any errors on your page, open your browser console. If there are any, you can either fix the errors at the application level (a preferable approach) or skip them during test run using the "-e" parameter.

Sinon with PhantomXHR - Window.sinon is undefined

I am using CasperJS along with PhantomXHR. When I run the code in webkit version I can able to mock the response but the same script is not working in Firefox using --engine= slimerjs. It launches the Firefox browser and shows the Page error as window.sinon is undefined. Any solution to get rid of this issue. Are PhantomXHR + sinon will support with slimerjs?
After so much struggle i have found that gloabl variable assigned to window is causing the issue.Just use sinon instead of window.sinon in phantomxhr

Using Protractor's 'browser' object with PhantomJS

I am trying to run a test suite written in Protractor headlessly (using PhantomJS), but when I run the command 'phantomjs testSuiteFile.js' I get the error: ReferenceError: Can't find variable: browser. The browser variable is important in all of my tests so is there a way to allow phantomjs to find & use the browser object?
I also tried configuring my protractor config file to use phantomjs, I started selenium webdriver for phantomjs using the command recommended in the docs: phantomjs --webdriver=9134 and ran the config file with protractor protractor.conf.js. The config file is set to only run myTest.js, and I now get the error E/launcher - Error: Error: Cannot find module 'webpage'. But myTest.js works when I run phantomjs myTest.js
myTest.js:
var WebPage = require('webpage');
page = WebPage.create();
page.open('http://google.com');
page.onLoadFinished = function() {
page.render('googleScreenShot' + '.png');
phantom.exit();}
This is not how Protractor and PhantomJS work together. You need to execute protractor command from the command-line to have browser and other Protractor global variables initialized.