I am developing a data scraping program by using xulrunner and .net I and able to achieve all the thing just I am unable to implement the logic to find similar elements on page ,details are as below
1) If I select any element/text then I get its xpath so I wish
Selects all similar elements page wide.I think we can achieve this by removing the position part from the selection xpath.
2) If I select any element/text then I get its xpath so I wish
Selects all similar elements next to the selected element
3)If I select any element/text then I get its xpath so I wish
Selects all similar elements within the parent element
I am really unable to understand how to implement it
Related
I am using a 3rd party scraper/crawler tool to pull in data from pages across a range of domains.
For example: Loading in the top 10 ranked articles for keyword 'x' and then pulling back elements of each page using some x path functions.
There are a couple of new elements I would like to start pulling, but I am not sure what the best approach would be to bring back the most accurate results.
Objectives:
Pull back the counts of ul, ol and li items across an article set
Pull back the text in each list element to compare how publishers
are writing on key topics
The issue is that I don't want to pull back navigation / menu elements that contain list items. I only want to pull in the data inside the body of each written article.
The easiest way might be to look for the H1 tag (since most sites only have 1 and its the main title of an article... and then pull the list items that show up AFTER the h1 tag. This should in theory eliminate anything in the main nav... but I am not sure how to do that in XPath.
Any idea on what the best approach might be to accomplish this?
I have automated the login and getting to the downloading page where i have some pdf's which i want to download. These pdf's are dynamic ,sometimes there are 10 sometimes 100 ,it changes everyday.i want to download those pdf's .
please find the attached image
Here i want to download the pdf by clicking each elements in column 3(hyperlink highlighted in blue colour) ,the number of rows in the table is dynamic.how can i do it using UIPATH.
From the top of my head, without knowing the application you are working in I see a few different approaches you can try:
Approach 1: Extract table as Data Table
Perhaps you can extract the table as a Data Table, enumerate the rows and find the individual link selectors you then can pass to a click activity.
Approach 2: Dynamically manipulating the selector
Use UIExplorer to find the selector of the link in the third column. Typically the attribute idx is the unique identifier. You can construct your own variable idx and in a while loop increment this variable while passing it to a click-activitys selector: "<your normal selector here someAttr="something" idx="+idx.ToString+"/>
This way, when the click fails with selector not found you will be at the last row of the column and you can exist the while loop.
Approach 3: Using Find Children
Another approach is to use the Find children activity on the column or table to get the children, i.e. the rows. You need to know which filter to use, it is basically the selector.
Find children outputs a IEnumerable<UIElement> you can iterate and pass to a click activity
The shared image is a perfect case of scraping a table from Web page which can be done through UiPath's Data Scraping Wizard, refer this tutorial. This will convert your html table into DataTable. This Data Scraping Wizard will take care of dynamin number of rows as well as the pagination (if exist).
Later, you've to iterate the DataTable (ForEach activity) and hit the link to download PDF files.
I'm trying to write some automated tests for this site https://www.jigsaw-online.com/basket/viewbasket
I'm trying to write a test to add or remove qty from a specific item added to the basket page.
I'm having trouble writing xpath that will get me the element for a button where the link contains some value in the href.
Take the add qty button for example this will be get me all the buttons on page
//button//i[#class='fa fa-plus']
This will get me all the items in the basket__items class where the link contains the product I am wanting to add qty to
//ul[#class='basket__items']//a[contains(#href,'12')]
I'm just having trouble combining these two pieces of xpath to get me the add qty button for the product I want to add too.
Can someone help me with this?
This is one possible way to combine the two XPath expressions (formatted for readability) :
//li[
contains(#class,'basket__row')
and
.//a[contains(#href,'12')]
]
//button//i[#class='fa fa-plus']
Explanation :
Basically, the XPath starts off with //li[contains(#class,'basket__row')], expression that select individual basket item row.
and .//a[contains(#href,'12')] in predicate narrow down the result to specific basket item row that you're interested in.
from this point, it is straightforward to incorporate your first XPath //button//i[#class='fa fa-plus'], which will return the button from the selected basket item row
I don't even know how to describe this :)
I have bunch of divs, with similar IDs that have random part added to each (the random part is different for each session). and deeply nested in one of them a bunch of radio input boxes, without anything I can tie to (also the whole tree under the div doesn't have unique attributes I can tie to).
I need the first radio button. I get the needed div with (//div[contains(#id,'div-question')])[2], and I thought I could follow it up with similar construct, but I can't figure out how. I Also tired following:
(//div[contains(#id,'div-question')])[2]//input[#type='radio' and position() = 1]
but it return me all radio buttons, not only the first one (I'm using FirePath from FireBug -- could it be it's bug?)
So, how do I join two //... searches?
//x[position()=1] returns every descendant x that is the first child of its parent. To select the first descendant x, you need (//x)[position()=1]. With a complex path it becomes easier to use the descendant axis explicitly rather than the // shorthand:
descendant::div[contains(#id,'div-question')][2]
/descendant::input[#type='radio'][1]
I've been using Ruby and Capybara for testing a web application. The current thing I'm trying to do is, while I'm within a window (and iterating through elements in the window), I clicked on a drop down menu item. The list of items in this drop down are not within the window's div, but the top most layer of the page.
The only way I was able to get the dropdown list to click the item I want was basically to do:
page.find(:xpath, "..").find(:xpath, "..").find(:xpath, "..").find(:xpath, "..").find(:xpath, "..").find(element I want) to iterate up parents until I got to the level the menu was at.
There has to be a cleaner way of doing this, as this type of searching is messy. Is anybody aware of a more simple way of going up to find elements?
Thank you in advance for any help the community can provide.
You might want to look at testing with Konacha and the Mocha testing framework with Chai. It's built for testing javascript and makes traversing the dom really easy.