want to use the xpath by using src tag

8,511 views
Skip to first unread message

snigdha narain

unread,
Jul 18, 2012, 4:11:02 AM7/18/12
to seleniu...@googlegroups.com
Hi All,

Can any body help to knw whether we can find the xpath by using src tag of a homepage logo of the URL : http://www.meritnation.com/  ,i m  trying in IDE ie xpath : //img[@src='/img/logo/new_logo.jpg'] but its not working...

but if i m recording it from Selenium Ide i getting 2 n 3 option:-

1)css=img[title="meritnation.com - now school is easy"]
2)//img[@title='meritnation.com - now school is easy']

help me

i m attaching the screenshot for better reference.
xpath issue.JPG

Mark Collin

unread,
Jul 18, 2012, 4:17:27 AM7/18/12
to seleniu...@googlegroups.com

A picture that shows no markup is useless for helping you to determine a valid XPath.

 

An XPath of //img[@src='/img/logo/new_logo.jpg'] looks sane, I would expect it to work if you have entered the path correctly.  The only place where this may go wrong is if the browser decides to prepend the domain to the src (I think IE used to do this at some point in the past, not sure if they still do).  You would be safer using one of the options IDE has suggested.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/hm1PNVp9foUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Krishnan Mahadevan

unread,
Jul 18, 2012, 4:24:20 AM7/18/12
to seleniu...@googlegroups.com
Snigdha,
replace

//img[@src='/img/logo/new_logo.jpg']

with 

//img[contains(@src,'/img/logo/new_logo.jpg')]

You should be good.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--

Peter Gale

unread,
Jul 18, 2012, 4:45:24 AM7/18/12
to Selenium Users
You need to match on the full src value, including the http:// bit ... not just part of it ...

Unless you use the Xpath contains function, like: //img[contains(@src,'/img/logo/new_logo.jpg')]


Date: Wed, 18 Jul 2012 01:11:02 -0700
From: snigdha...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] want to use the xpath by using src tag

snigdha narain

unread,
Jul 18, 2012, 5:30:46 AM7/18/12
to seleniu...@googlegroups.com
Peter n krishnan thanks a ton! its working...

smartmouse

unread,
Oct 7, 2013, 4:01:46 PM10/7/13
to seleniu...@googlegroups.com, snigdha...@gmail.com
Hello, i need help about XPath syntax that i have to use with Wordpress (FeedWordpress plugin).

I have this RSS link:

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xml:lang="en-US">
	<channel>
		<title>MySite</title>
		<link>http://www.mysite.com/index.php</link>
		<description><![CDATA[Live information from MySite]]></description>
		<item>
			<title><![CDATA[This is a test]]></title>
			<link>http://www.mysite.com/index.php/topic,13177.0.html</link>
			<description>
<![CDATA[<img src="http://s10.postimg.org/5zbyeuugp/testing2453.jpg" alt="" class="bbc_img" />

I'm testingTesting this right now]]>
			</description>
			<author>it...@email.com</author>
			<comments>http://www.mysite.com/index.php?action=post;topic=13177.0</comments>
			<category><![CDATA[That section]]></category>
			<pubDate>Tue, 01 Oct 2013 22:26:56 GMT</pubDate>
			<guid>http://www.mysite.com/index.php/topic,13177.0.html</guid>
		</item>

How to catch <img src="..."> string with XPath-like syntax?
How to fill the "Value" field?

This is the FeedWordpress feature i'm talking about:
http://img822.imageshack.us/img822/2333/5sw9.png

Reply all
Reply to author
Forward
0 new messages