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.
Related
I am trying to click on Supplier. I've added a screen shot of the source code. In this code sample I have successfully logged into the site, but the next step is to click on that dropdown to get to the next screen. I have hard coded the link and then used GET to call open the URL string. However, it's my understanding that I should be able to do this without hard coding the URL for Supplier. I should be able to pull it with a single line of code versus trying to figure out how to loop through somehow to get to the "Supplier" selection. I am trying to account for the scenario if this link changes so I want my code to pull it directly from the source vs hard coding. I've uploaded a screen shot of the source code. How can I click on supplier?
Dim ch As New Selenium.ChromeDriver
Dim FindBy As New Selenium.By
ch.Get("URL", raise:=False)
ch.SwitchToFrame("MainFrame")
ch.FindElementById("ctl04_txtUsername").SendKeys(Form1.TxtBId.Text)
ch.FindElementById("ctl04_txtPassword").SendKeys(Form1.TxtBPass.Text)
ch.FindElementById("ctl04_btnLogin").ClickDouble
str = "https://am.adech.net/csge/portals/postmodern/desktpdefault.aspx?tabindex=1&tabid=211&sTarget=S"
ch.Get str, Raise:=False
The answer to my question is:
First find the element by ID, find that elements anchor by tag, next getattribute by "href" and then navigate to that anchors "href" link.
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.
I have 20 or so grids in my application suite. I'd like to create a global copy/paste context menu which I can bind to every single grid rather than code in each form.
I am unsure what is the best way to achieve this, I have started to create a class with my menu in it, but get stuck at the point of adding the actual menu options. For example I know I'll need to call a "copy" event, but I also know I'll need to tell it what I am copying, and I cannot see how that is done in vb.net when you can only add the address of a method minus parameters.
e.g.
.MenuItems.Add("Copy Cell", New System.EventHandler(AddressOf CopyCell))
Obviously I want "CopyCell" to only be coded in one place as well, rather than repeated in each form. I will always be copying the same object (SelectedCellCollection).
I am not sure how to make the menu have an event with parameters, or how to make it "know" that I want to always copy the selected items. I'm aware that I'd have to do some coding in the form but just trying to work out the way to minimize it.
I have created my own context menu class (via inheritance) with specific copy and paste functionality / options tailored to the grid I am using. It works fine and only needs one line of code per form/grid to activate.
In Pass.Json file, how to write a code for adding button and how to add hyperlink text, which dynamically update the link, after user click the hyperlink text?
Please let me know if someone come across with same requirement.
You cannot add a button or hyperlink to a pass.
There is a fairly clumsy workaround to update a pass based off a user action that takes advantage of the fact the URLs, phone numbers, dates and addresses that appear on the back of the pass are automatically made clickable.
So while you cannot add a button or hyperlink text per-se, you could add a link to a script that when clicked on, triggers a push update that updates the pass with your new content. This pass contains a good example, and the source code is available here.
I have a tab control with two tabs. Both tabs have controls which are unique to them, but there is one control which I would like to always appear on whichever tab is currently active.
I figure I just need to add some code to TabControl1_SelectedIndexChanged().
I tried
MyControl.Parent = TabControl1.TabPages(
TabControl1.TabPages.IndexOf(TabControl1.SelectedTab))
MyControl.Parent.Update() ' is this necessary?
and I also tried
TabControl1.TabPages(
TabControl1.TabPages.IndexOf(TabControl1.SelectedTab)).Controls.Add(SeMyControl)
but neither worked (the control moved once, but when I went back to the original tab, the control did not appear there.
googling found someone suggesting
TabControl1.TabPages(TabControl1.TabIndex).Controls.Add(MyControl)
but that looks dodgy as the control is never removed from the old tab, so repeated switching would probably add the control multiple times.
I feel that I am close, but not quite ... how do I do it?
No, that works fine since Controls.Add() changes the Parent property. Which automatically removes it from the tab page it was on before. A control instance can only have one parent.
The more straight-forward approach is to simply not put the control on a tab page but leave it parented to the form which a lower Z-order so it is always on top of the tab control. The only problem with that is that the designer will hassle you. It automatically sucks the control into the tab page when you move it on top of the tab control. One trick to fix that is to leave it off the tab control and change its Location property in the form constructor.
Using your second code snippet that you are concerned about because it doesn't remove it from the original tab, why not just remove it from the original tab before you add it to the new tab?
Maybe something like: TabControl1.TabPages(TabControl1.TabIndex).Controls.Remove(MyControl)