Using puppeteer to automate button clicks for every button at every URL in a web app - automation

I am currently trying to use JS and puppeteer to take a screenshot of every url in my web app, as well as take a screenshot of every button that can be clicked. Is there a way to click each button without specifying the id? Not all of my buttons have an id and even if they did, I wouldn't want to have x number of page.click(id, options) for each button I have (which is quite a lot).
Thanks
I have tried going based off each className (this app is built using react) but this does not work. It will take a screenshot of the same buttons over and over. I believe because if page.click has multiple of the same options, it only chooses the first one and many buttons have the same styling classNames.

You could get an array of each element on a page, go through the elements with a for loop determine if it is a button, then click it. Then for each page you'd have to input each url in an array and then use a for loop to go through it.

Related

Attaching a new tab without use of "Title"

I have a piece of automation that uses a handful of links to traverse to a required new tab. Once that tab is open, another set of rules handles how to utilize it. The problem is the site I am using has completely different names for each tab that is opened this way. I have tried attaching the browser with just a "*" for the HTML title (in hopes that it grabs the most recent active tab), but this doesn't seem reliable. I know you can capture the browser instance and pass it around as a parameter, but I haven't seen where I can grab the instance of the newly opened tab.
To maybe make this easier to follow:
attach browser
click a bunch of links
final link opens a new tab, with essentially a random title
another piece of code needs to pickup where the last one left off
so if I can either get the instance of the new tab to pass to the second set of code, or a way to attach the new tab to second set of code without the use of the "title"
I hope this makes sense. Any help is appreciated.
As I have understood, you have a browser, with a website. On that page you click on links to open them in new tabs. So far so good. Now you would like to switch to these new tabs.
So as there is no way to solve this in UiPath, I could think about a workaround that works in any browser without any plugin.
Steps to solve it:
Having all new tabs opened and the base tab is active in your browser
Get the tab title via Get Attribute activity and save it as String variable MainTabTitle
Now add a Do While loop
In the loop you add the following things:
If you use Firefox, add the Hotkey CTRL+Tab, this will let you go to the next tab
Add a Get Attribute activity (that extracts the title of the tab)
Save the name into a Dictionary or something similar with an Assign activity
Do this until you reach the first tab again (you can determine the first tab with checking your MainTabTitle)
Then at the end of the Do While loop you now have the logic:
We should have now all the tabs (except the first) in the Dictionary
Now take the title of the first entry of that Dictionary
That title is now used as the Attach browser scope that you need to use to give the tab the focus
That's it. I would say a proper way to solve this.

how to keep second pdf page hidden until button is selected on first page

I've created a pdf user form with the option to only put 10 line items, however, if the user requires to insert additional item codes, I've created a second form for just that. I would like to know if it is possible to keep the second document hidden until the user clicks a button to activate the second sheet - making it accessible to insert addition item codes if needed. Thank you for your help in this matter.
I'm not sure I understand your intent completely from your question. If you you wish to display your PDF forms as separate pages, it's as simple as this HTML:
<button onclick="location.href='SecondPage.html';">Show More</button>
Where "SecondPage.html" becomes instead the URL of your second PDF.
If you wish instead to display the two PDFs on the same web page simultaneously, we'd probably need to see some markup of what you've tried so far. You generally get better answers on StackOverflow if you can present examples of what you've tried so far.
But your general approach would probably be a simple one: Put both PDFs into DIVS with styles applied so that the first DIV is visible and the second DIV is hidden. Then, the onclick for the button I've written above, instead of displaying a page, would simply call a javascript function that alters the style for the second DIV, changing its style from "hidden" to "block".

Can not click on element via TestComplete object mapping

I need to click on a web element, within TestComplete, this element looks like this:
I outlined its boundary using heavy-black line.
The problem is, by default, an element is always clicked in its middle point, and for this element above, clicking its middle point produces no results as it does not click this plus sign.
Within TestComplete, this element can not be broken further down into smaller elements.
I can use Selenium in JavaScript to click it, but is there is an other way?
Thanks
Try using x and y coordinates with the Click method.
SmartBear Click Action
I needed to click a button on my website but TestComplete was only able to identify the parent object which had 3 buttons in it. I was able to use x,y coordinates to press the 3 different buttons in parent object.
Record a script where you click the button and look at the function created to get the coordinates you need.

How do I implement this type of dynamic UI in a Razor view?

I will start by saying that I am an absolute newbie to web development and to MVC as well.
I want to implement a view for a Subscriber page (part of an MVC4 application dealing with Email marketing). What I want to implement is:
1) When the user clicks the "+ Add a List" button, a new Category should appear on the left and the cursor should blink, meaning it should be ready to receive the name for the category from the user. I also want that whenever the user hovers over any category name on the left, a small bar containing two buttons (edit and delete) should appear which should let the user edit the category name or delete that category. The thing I want is that all of these must happen without reloading the page.
2) When the user clicks the "+ Add Contact" button, a pop up dialog box containing two tabs should appear which lets the user either manually enter the details or upload a CSV to capture the details. Whenever the user clicks the "Add Contact" button or "Upload and Add Contacts" in the pop up dialog box, I want the new contacts to display in the contact list region shown in the picture (once again, without reloading the page). I also want the same hover bar for the contacts too (same as categories).
I am confused as to how to implement this in a Razor view? What do I use - JavaScript/jQuery/AJAX?
I am pretty much lost. Can someone please guide me a little bit so that I can continue and finish my first MVC4 project?
You need some javascript libraries like jQuery UI or maybe Kendo UI, I'd recommend to use jQuery UI at this time. they have many widgets but look at these. and keep in mind that a cshtml view can be look upon like a html page, you can have all tags, css and javascript you want there:
http://jqueryui.com/dialog/
http://jqueryui.com/tabs/
http://jqueryui.com/

bring page to foreground? multipage editor

I'm develpping an RCP user interface. I have a multipage editor in which pages are editors (EditorPart). From a first page in my multipage editor I want to open a second one if a button is pressed. I've managed to do that but the problem that I'm facing is that the created page is visible only if we switch to it, i.e only the tab is visble.. what I want is to directly switch to the new page automatically after its creation. In other words, how can I bring the new page to foreground exactly when it is created.
Can you help me please
Kind Regards,
Jean
It seems to me that the calling the method org.eclipse.ui.part.MultiPageEditorPart.setActivePage(int) should do the trick.