problem in identifying .gif image using selenium web driver.

828 views
Skip to first unread message

supriya

unread,
Mar 14, 2012, 3:46:23 AM3/14/12
to Selenium Users
i m trying to automate ibibo login using facebook id. but the
corresponding link is in .gif image and not able to get xpath of dat
even using firepath. please let me knw how to do this.....

Krishnan Mahadevan

unread,
Mar 14, 2012, 8:47:12 AM3/14/12
to seleniu...@googlegroups.com
XPath that you are looking for would be : //img[contains(@src,'login-fb-btn')]

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
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.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Subbarao

unread,
Mar 14, 2012, 11:45:11 PM3/14/12
to seleniu...@googlegroups.com
Hi,

firepath gives the exact xpath value of the element?

--
Thank you
P. Subba Rao.

supriya singla

unread,
Mar 15, 2012, 1:44:23 AM3/15/12
to seleniu...@googlegroups.com
yup, by recording IDE, it is taking css path. but when i did the same coding then it is not doing as expected. Could u plz tel me wt is d diff b/w xpath or css path. means where (for which type of elements)we use css path?

Thanks alot u all for responding.
Supriya Singla

raghu nandan

unread,
Mar 15, 2012, 1:47:19 AM3/15/12
to seleniu...@googlegroups.com

identfying elemnt preference better to use CSS fisrt,then ID , then name,then classname....last will be XPATH.

all-ready duscussed in group
with regards
RaghuNandan

supriya singla

unread,
Mar 15, 2012, 1:51:09 AM3/15/12
to seleniu...@googlegroups.com
ok. Thank you so much. actually i m new in this group, joined yesterday and new to selenium webdriver and facing lots of problems. I think i need more search.

Thanks 
Supriya Singla

supriya

unread,
Mar 15, 2012, 3:00:36 AM3/15/12
to Selenium Users
Hello Sir,
I tried ur proposed solution but getting the following error.

http://www.ibibo.com
Errororg.openqa.selenium.InvalidSelectorException: The given
selector //img[contains(@src,'login-fb-btn' is either invalid or does
not result in a WebElement. The following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath
expression //img[contains(@src,'login-fb-btn' because of the
following error:
[Exception... "The expression is not a legal expression." code: "51"
nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)"
location: "resource://fxdriver/modules/atoms.js Line: 2392"]
Command duration or timeout: 151 milliseconds
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/invalid_selector_exception.html
Build info: version: '2.19.0', revision: '15848', time: '2012-02-08
16:25:03'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0'
Driver info: driver.version: RemoteWebDriver

On Mar 14, 5:47 pm, Krishnan Mahadevan

supriya

unread,
Mar 15, 2012, 3:01:26 AM3/15/12
to Selenium Users
yes, it gives exact path as well as relative path.

On Mar 15, 8:45 am, Subbarao <subbuparit...@gmail.com> wrote:
> Hi,
>
> firepath gives the exact xpath value of the element?
>
> On Wed, Mar 14, 2012 at 6:17 PM, Krishnan Mahadevan <
>
>
>
>
>
>
>
>
>
> krishnan.mahadevan1...@gmail.com> wrote:
> > XPath that you are looking for would be
> > : //img[contains(@src,'login-fb-btn')]
>
> > Thanks & Regards
> > Krishnan Mahadevan
>
> > "All the desirable things in life are either illegal, expensive, fattening
> > or in love with someone else!"
>

Mallikarjun Yalagi

unread,
Mar 15, 2012, 3:04:29 AM3/15/12
to seleniu...@googlegroups.com
Hi,
    when you recorded using ide ,that time also u r getting error or u r getting error only when u r  coding???

supriya singla

unread,
Mar 15, 2012, 3:06:00 AM3/15/12
to seleniu...@googlegroups.com
hii
 i m getting tjhe error when coding.
Thanks

Mallikarjun Yalagi

unread,
Mar 15, 2012, 3:09:38 AM3/15/12
to seleniu...@googlegroups.com
means  working fine in ide , take css of that which you got in ide ,before css put Thread.sleep(5000); and check.
 
Thanks&Regards
Mallikarjun yalagi

supriya singla

unread,
Mar 15, 2012, 3:12:50 AM3/15/12
to seleniu...@googlegroups.com
yes, i have done the same. still not working.
Thanks.

Krishnan Mahadevan

unread,
Mar 15, 2012, 3:38:10 AM3/15/12
to seleniu...@googlegroups.com
Supriya

Take a closer look at the error

Errororg.openqa.selenium.InvalidSelectorException: The given
selector  //img[contains(@src,'login-fb-btn' is either invalid or does
not result in a WebElement. The following error occurred:
[InvalidSelectorError] Unable to locate an element with the xpath
expression  //img[contains(@src,'login-fb-btn' because of the
following error: 


arent you missing a )] a close bracket as well as a close square bracket ? Copy paste errors perhaps ?


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



supriya singla

unread,
Mar 15, 2012, 3:41:08 AM3/15/12
to seleniu...@googlegroups.com
yes yes. Thankyou so much. let me check.

supriya singla

unread,
Mar 15, 2012, 3:58:27 AM3/15/12
to seleniu...@googlegroups.com

After opening the browser with corresponding url, i used:
try{
Thread.sleep(10000);
}
catch(Exception e){
System.out.println(e);
}


driver.findElement(By.xpath(" //img[contains(@src,'login-fb-btn')]")).click(); //login with fb


and now facing the following error.


Errororg.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":" //img[contains(@src,'login-fb-btn')]"}
Command duration or timeout: 100 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.19.0', revision: '15848', time: '2012-02-08 16:25:03'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0'
Driver info: driver.version: RemoteWebDriver


Krishnan Mahadevan

unread,
Mar 15, 2012, 4:07:05 AM3/15/12
to seleniu...@googlegroups.com
Supriya,
Your image is residing within a frame named "fconnect". You would need to switch to this frame and then try to fetch that element using the xpath that I shared earlier.

Below is the html snippet of the frame that I am talking about.

<iframe scrolling="no" height="26px" frameborder="0" width="180px" style="overflow: hidden; margin-top: 5px;" src="http://link.ibibo.com/fblink.php" name="fconnect" border="0" marginwidth="0" marginheight="0" id="fconnect"></iframe>


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


jeevan

unread,
Mar 15, 2012, 4:09:24 AM3/15/12
to seleniu...@googlegroups.com
Supriya,

Ur missing one thing....ur getting the exception because element presents in the frame so...u need to switch to that particluar frame and perform some actions on that..

Like below..its working fine

    @Test
    public void t() throws Exception{
        driver.get("http://www.ibibo.com");
        Thread.sleep(5000);
        driver.switchTo().frame("fconnect");
        driver.findElement(By.xpath("//img[contains(@src,'login-fb-btn.gif')]")).click();
    }

Thanks,
Jeevan

supriya singla

unread,
Mar 15, 2012, 5:06:34 AM3/15/12
to seleniu...@googlegroups.com

Krishnan Mahadevan

unread,
Mar 15, 2012, 5:14:37 AM3/15/12
to seleniu...@googlegroups.com
Supriya,

In the selenium forums we try to stick to a convention which is post on threads which are relevant to the original topic.

From your question, it seems like the original problem for which you had posted a query has been resolved and the follow up questions arent related to the original post (We call this as thread hijacking).

Would appreciate if you could please start a new thread on your question, so that when someone else is looking for specific help in the selenium forums he/she finds answers in a simple and easy way.

Cross posting on threads makes it increasingly difficult for people who search through forums for answers.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



supriya singla

unread,
Mar 15, 2012, 5:17:03 AM3/15/12
to seleniu...@googlegroups.com
Ok.Seems Right.

Thanks 
Supriya

supriya singla

unread,
Mar 15, 2012, 5:18:37 AM3/15/12
to seleniu...@googlegroups.com

May u please tell me how did u find this xpath?
Thanks
supriya

Krishnan Mahadevan

unread,
Mar 15, 2012, 5:21:00 AM3/15/12
to seleniu...@googlegroups.com
I made use of XPather plug-in to start off with, and then I fine tuned it with XPath functions to get the right value.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


supriya singla

unread,
Mar 15, 2012, 5:42:07 AM3/15/12
to seleniu...@googlegroups.com

ok.
Actully i was using firepath.
Thanks 
Supriya
Reply all
Reply to author
Forward
0 new messages