I am implementing an application with Javascript and html that will be executed in browser. In my application I would like to use puppeteer for Web Scraping. I put the puppeteer code in js file, but it doesn't work. Is it possible to run puppeteer in java scrip running in browser or it has to be executed by node?
You can't run Puppeteer without Node.js, Puppeteer IS a node.js library, the first line of the docs says
Puppeteer is a Node library
Related
I created a website using HTML, JS and tailwind CSS. The tailwind CSS was installed using the CLI tool following the procedures in the documentation and is working fine when the page is executed with live server in Visual Studio Code.
npm install -D tailwindcss
and then created a tailwindcss.config.js with
npx tailwindcss init
Now the problem is, how do I share this whole website to a friend so that he can simply run the index.html file and he sees a completely working website running the tailwindcss code too without him having to install and configure tailwindcss. Or if there is a way to export the project with all installed packages.
Because so far, it just runs the plain html code whenever I try to share the whole project or even if I simply try to execute the page outside VsCode.
what I see from VsCode live server
what I see when running the page outside VsCode
Perhaps a possible solution to share is to host a live project on an online editor, this example uses Vite to build an environment for Tailwind and Vanilla JavaScript, it does not have much configurations but can be forked to try.
If other tools are preferred, consider start a new project in such online editor from a template with Tailwind, or start a new Node.js project and use the terminal to install needed packages.
We know that ng serve command used to run the app.
Also, we would like to know what all other ways to run the app.
ng serve command is used in the development process to check parallel the result. Whatever in the html written can be reflected in the browser.
I'm facing up a strange problem in Puppeteer with authentication.
I've written a script to take some screenshot of a website which required authentication.
In my local computer (windows), when running in command line as node.exe my_script.js; it's working fine (in headless moden which is the default mode).
I've written an upper Java program to manipulate it (dynamically set the path, the node modules path, run the process "nodex.exe my_script.js" every 30minutes, manage timeout of the process,...). It's still working directly running from Eclipse, in headless mode.
Then... I've built/packaged a JAR and running it in a cmd window: java -jar my_jar.jar... and then the script can't authentitcated on the website in headless mode (the answser page just write a message like "you need to be authenticated", which is managed by the http server).
To check what happen, I've just add an option in my nodejs script (so I do not modify my java upper program code) to run chrome in non headless mode; with option headless : false. And... it's working!
I let the option to run in non headless mode, and I create a Windows service to run my jar via a bat file, with the help of nssm... Just to test. I'm really happy to see that all is running fine without seeing any chrome GUI (maybe Windows disable GUI for service, don't know how).
Have I maybe missed something? Or is there a bug in Puppeteer or Chrome to manage authentication in headless mode?
Regards
Alex
I have WebStorm successfully launching my app when I hit debug. It runs the app in chrome and Chrome tells me that that tab is in debug mode.
But it will not break on any breakpoint. I am using Ext JS and in the root app.js I have a breakpoint on the launch: function (which is being called) and that does not drop me into the debugger.
Does the WebStorm debugger not work with Ext JS?
I have the same situation as yours, except that I'm building my app using Backbone.js and RequireJs and the app is running on localhost. My app can run in debug mode in Chrome but the breakpoints cannot be hit.
I solve the problem by mapping the Remote URL and my local directory. You can define this in your JavaScript debug configuration profile in the Run->Edit Configurations.
You can refer to this wonderful tutorial: Debugging your JavaScript app using WebStorm.
Happy debugging!
Is it possible to build a custom google chrome extension to run selenium commands when it detects a specific Url/page?
Where to begin? How would you run selenium commands via a google chrome extension?
First install selenium IDE and record all your test cases into it [This is to save your time in writing test cases].
Then get selenium RC binaries for your preferred language (for me its C#). Create your project and take reference of selenium RC binaries. Import all test cases from above selenium IDE in your preferred language and add those into your project.
When you will import the test cases from IDE default browser will be *chrome(i.e. Firefox). To change it to Chrome change browser type when we are creating selenium object
selenium = new DefaultSelenium("localhost", 4444, "*googlechrome", "http://www.google.com/");
To run your project you have to first start selenium server. Here is the guideline for the same.
Note: You can also use selenium web driver in place of selenium RC. And I think if you use web driver then you no need to run selenium server to execute your test cases/project.