I want to extract a list of dates from a hidden input, but I really don't understand what I'm doing. On the web page there's code similar to:
I'm trying the xpath:
//input[#id="dates_list"]/#value
But that leaves my HTML column empty in import.io. (At least I have a blue underline on my xpath, instead of red, so I think I have the syntax correct.)
Based on the code
//input[#id="dates_list"]/#value
is not targeting your example , it should be like this
//input[#id="showtime_dates_list"]/#value
also in this case the column type Should be Text , if you need the html you should make it like this
//input[#id="showtime_dates_list"]
Related
For example, I have div tag that has two attributes.
class='hello#123' text='321#he#321llo#321'
<div> class='hello#123' text='321#he#321llo#321'></div>
Here, I want to write xpath for both class and text attributes but numbers may change dynamically. ie., "hello#123" may become "345" when we reload. "321#he#321llo#321" may become "567#he#456llo#321".
Note: Need to write xpath in single line not separately.
Assuming that you have the (corrected) two-attribute-HTML
<div class='hello#123' text='321#he#321llo#321'>...</div>
you can select it using the following, for example:
Using the contains() function
//div[contains(#class,'hello') and contains(#text,'#he#')]
This is quite specific and only applicable if the "hello" is always split in the same way
Using the translate() function to mask everything except the chars for "hello"
//div[translate(#class,'#0123456789','')='hello' and translate(#text,'#0123456789','')='hello']
This removes all # chars and digits and checks if the remaining string is "hello"
I guess combining these two approaches you will be able to create your own XPath expression fitting your needs. The patterns you provided were not fully clear, so this may only approach a good enough solution.
I'm trying to find the xpath for an element that contains three dots instead of text. Once I expand the element by clicking on arrow in DOM model html it returns the text.
The following xpath returns nothing unfortunately:
//button[contains(text(),'Pending')]
What's the right solution?
The text content of that element is not a three dots but Pending (). You see the ... only because there is no room to present the text there until you expand the element. So, generally this //button[contains(text(),'Pending')] should work.
You can also try this XPath expression:
//button[contains(.,'Pending')]
It means "a button element with any attribute containing Pending value"
It is more general and should work.
To understand why //button[contains(text(),'Pending')] did not work see this post or this. There are more explanations about this.
I'm currently trying to fill a smartform with some information. I have a simple text element and read the data fields via &name&. The data itself gets read perfectly fine, however the layout is incorrect. Some fields are just plain text, and others are defined as packed numbers with 2 decimals. These packed number fields for some reason are out of alignment, always showing one line below everything else that is supposed to be in this line. That looks like that:
How can I get the 121,08 in this example on the same height as the rest? The text element looks like the following:
test &field1& &field2& &field3&
Only field 2 is a packed number, therefore I think it might have something to do with that.
Use as below. C will remove extra space.
&field2(C)& &field2(C)& &field3(C)&
Given that I have the following XPath:
//table[#title="someTitle"]//td[#id="someId"][3]
When I try to click on this element using WebDriver's element(By.xpath(someXpathString)).click(); I get the "ElementNotFound" exception.
However, when I try finding the element using the SAME XPath but using the console in Chrome DevTools it returns exactly the element that I'm looking for. The call looks like this:
$x('//table[#title="someTitle"]//td[#id="someId"][3]');
Now, I know that if I use THIS XPath:
(//table[#title="someTitle"]//td[#id="someId"])[3]
in WebDriver, the element is found and click works.
Please note that I want to be able to find the 2nd, 3rd or even 4th element by that selector. This is a workaround for interacting with table cells on the same column but different rows.
My question is: why does the Chrome console recognize the element using the XPath without parenthesis while the Find function does not, and what is the actual difference between the two XPaths?
I've noticed on other elements that the parenthesis notation is NOT needed in order to select the 2nd or higher element of that type, so I would like a clear explanation on how this type of XPath works, what is the logic behind it.
Both xpaths are different.
//table[#title="someTitle"]//td[#id="someId"][3] -- will select only 3 column elements
(//table[#title="someTitle"]//td[#id="someId"])[3] -- selects all columns and then returns only one element indexed at 3.
For example assume a table with 4 rows and 4 columns.
First xpath selects only elements in the third column of each row (total 4).
But second xpath slect only one element, ie column number 3 at row 1, irrespective of number rows in the table.
if we use find element, both will return only one element. But if we use find elements, first will return 4 elements but second xpath returns only one element.
If you are going to the page where your element is from another page, try refreshing -
driver.navigate().refresh();
I need to generate an URL string for a SSRS report (in order to link it with our CRM software). The report name is in Hebrew. When I send the URL string (with Heb) to Internet Explorer, it doesn't recognize the address because it isn't encoded with Percent-encoding (BTW, it works fine in Firefox). (Sending a URL with English only does work fine that way.)
Anyway, I tried to perform the encoding. I succeeded converting it to URI with UNICODE characters. I need to get the URI in UTF-8. For example, the letter 'י' should be converted into '%d7%99' and not to '%05%D9'.
I included a link:
A table with the codes, for your use, if needed.
I need the conversion\encoding function for 1 character. I can build the rest of the script / function for the complete string by myself.
I used a script which used the master.sys.fn_varbintohexstr function. As I said, though, the results aren't proper for IE.
the following:
SELECT master.sys.fn_varbintohexstr((CAST (N'י' AS varbinary)))
will get 0xd905, which I formatted into percent encoding. I should get 'd7 99' instead.
wrap up:
I convert an Hebrew character into URI percent encoding. I get a unicode result. I wish > to get a utf8 result.
Input = 'י'. Current output = %d9. Wanted output = %d7%99
How can I get those results?
I have had to deal with a few similar problems and there are two approaches that you may wish to consider; the first is to transform your data into HTML in the query and then render the result as HTML in the RDL, the second is to use JQuery to identify those cells with the incorrect value on the client and then transform that cell (again, using JQuery). The benefit of the second option is that if the server rendering is working on Firefox the transformation overhead doesn't get invoked. The downside is that if you are not rendering the report as HTML it won't work.
For the first option, in the select statement you would need to alter the appropriate column to produce a nvarchar value that looks like
<span style="font=yourfont;" charset="UTF-8">linkname</span>
With that string as data you then assign that to the appropriate columns (or cells, as needed)
In the RDL designer drag a placeholder for your field onto the designer and right click the placeholder and select placeholder properties then you can select to display the content as HTML.