Create dynamic Xpath - xpath

I want to click on 'Select' where preceding block contains text, "Byron Test 20150904". This text is dynamic

After trial and error i find the answer
//div[#id='itOverview']/div[.//a[contains(text(),'Byron Test 20150904')]]/div/div[3]/div[2]/a

Related

How to extract items inside a table using scrapy

I want to extract all the functions listed inside the table in the below link : python functions list
I have tried using the chrome developers console to get the exact xpath to be used in the file spider.py as below:
$x('//*[#id="built-in-functions"]/table[1]/tbody//a/#href')
but this returns a list of all href's ( which I think what the xpath expression refers to).
I need to extract the text from here I believe but appending /text() to the above xpath return nothing. Can someone please help me to extract the function names from the table.
I think this should do the trick
response.css('.docutils .reference .pre::text').extract()
a non-exact xpath equivalent of it (but that also works in this case) would be:
response.xpath('//table[contains(#class, "docutils")]//*[contains(#class, "reference")]//*[contains(#class, "pre")]/text()').extract()
Try this:
for td in response.css("#built-in-functions > table:nth-child(4) td"):
td.css("span.pre::text").extract_first()

Is it possible to use Following and preceding in combination in Selenium?

On this page
https://en.wikipedia.org/wiki/Trinity_Seven#Episode_list
I have:
//*[text()='Reception']//preceding::th[contains(#id, 'ep')]//following::I
But it only registers following.
The default firepath selector is: .//*[#id='mw-content-text']/div/table[5]/tbody/tr/td[1]/I but this kind of selector is known to break quite frequently. Just wondering if there is a better way of doing this and I thought this might be a way.
Thanks!
:)
- You can see that it's getting stuff under the table which is not what I want :S
Try to use below XPath to match required elements:
//th[contains(#id, 'ep')]/following::I[./following::*[text()='Reception']]
This looks more simple
//tr[contains(#class, 'vevent')]//i
Don't overcomplicate things. You need I tag inside each row. So just find row locator tr[contains(#class, 'vevent')] and get it's I
Another good approach in case you want to check that inside of parent element is located some special element, but you want to find some 3rd element is to use such style: //element[./specific]//child , so in your case:
//tr[contains(#class, 'vevent')][./th[contains(#id,'ep')]]//i
so it's I tag inside row that contains #id,'ep' in header

X-Path Query won't work in Google-Sheets

I've been trying to use the following X-Path within Google-Sheets with the =ImportXML function
=importXml("http://www.managetickets.com/morecApp/ticketSearchAndStatusTicketList.jsp?msgCount=23&outputEmail=&db=nd", "/table[2]/tbody/tr#[td]")
But no matter what minor adjustments I try I continually get "#N/A" with a hover-text box that says "imported content is empty".
I know it's a valid x-path, I've cross verified it with 'X-Path Helper Wizard' chrome-extension.
Any ideas what I'm doing wrong!?
No, actually it's not a valid XPath. Note that # used to select an attributes e.g. #class, #id, etc. Also it's a bad idea to use tbody tag in your expressions as this tag is not always present in initial source code
So if you want to match table rows which contain cells from second table, you can use
/table[2]//tr[td]

how can i use regexp in birt report and replace

when i use birt, my data with sql query are contains many html tags,like
[quote][/quote]
[img][/img]
,i prefer to replace it with regexp,but i can't successful,
i print
<VALUE-OF>row["content"].replace(/\[\/?[a-z]*\W*\w*]/gi, "")</VALUE-OF>
in 【edit text item】,
also i wrote 【data banding】 in expression with
dataSetRow["content"].replace(new RegExp("/[\[]\/?\W*]/g","ig"),"")
it failed,i have no idea
I use the wrong method ,the right is replaceAll()

xpath find text within a table

I am trying to find and select the text "Paris" within a dynamic table. When I run my selenium tests it can find the table and it can verify the text "Paris" exists however it cannot click Paris
I think it's something like this:
/html/body/div[class='yui-dt-liner']/td/tr[contains 'Paris']/div
Or:
//div[class='yui-dt-liner']/table/tr[contains text(), "Paris"]/div
But I can't get it to work. Any help will be appreciated.
Besides the "cannot click Paris" part (very much a Selenium specific type of question), both expression you'd provide are not sintactically correct.
Probably, they should be:
/html/body/div[#class='yui-dt-liner']/table/tr/td[contains(.,'Paris')]/div
And
//div[#class='yui-dt-liner']/table/tr/td[contains(.,'Paris')]/div
Note: # abbreviated form of attribute:: axis. Correct contains() function syntax. You should better use the string value of the element (. is the abbreviated form of self::node()) instead of the first text node child.

Resources