Share
Go down
avatar
Joffre
Posts : 5
Join date : 2013-06-03
Age : 29

How to map an element? | Como mapear um elemento?

on Mon Jun 03, 2013 8:52 pm
Hi all.

How can I map the menu (menu.jpg)? I'm using selenium-server-standalone-2.33.0, on a Java app.

I've tried using the easier way, using the function findElement(By.id()) but it didn't work. I think I'll have to use XPath, but I have no idea how to do that.

I've attached the HTML script either (html.jpg). Any ideas?

Thank you!

-----

Olá a todos.

Como posso mapear o menu em anexo (menu.jpg)? Estou usando selenium-server-standalone-2.33.0, em uma aplicação Java.

Tentei usar da forma mais fácil, usando a função findElement(By.id()) mas não funcionou. Creio que precisarei usar XPath, mas não tenho idéia de como fazê-lo.

Anexei o script HTML da página também (html.jpg). Alguma ideia?

Obrigado!

-----

Images:


menu.jpg


html.jpg
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Re: How to map an element? | Como mapear um elemento?

on Tue Jun 04, 2013 10:51 am
You could try this to find element -

WebElement element = driver.findElement(By.className("middle"));

and then perform operation on "element" like - click etc.

Notice that I am using class to identify element here.
The order of element identification would usually be -

id>name>css selector > xPath

Hence xPath should be last resort to identify an element.

_________________
Thanks
Tarun K
Free Selenium Training
avatar
Joffre
Posts : 5
Join date : 2013-06-03
Age : 29

Re: How to map an element? | Como mapear um elemento?

on Tue Jun 04, 2013 5:55 pm
Hello tarun3kumar, thanx for your answer. However, the 'class='middle' isn't unique as you can see on the image below.



Any more ideas?! =x

Thank you!


Last edited by Joffre on Tue Jun 04, 2013 5:55 pm; edited 1 time in total (Reason for editing : arranging the text)
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Re: How to map an element? | Como mapear um elemento?

on Wed Jun 05, 2013 1:15 pm
hm, In that case we can navigate from parent node.
Seems class "menu-bar" is constant hence you can try this -

//div[@class='menu-bar']/span[@class=menu-button][4]/span[@class='middle']

that is - get the fourth span of parent div and then get the span with class 'middle'.
Let me know if this helps.

_________________
Thanks
Tarun K
Free Selenium Training
avatar
Joffre
Posts : 5
Join date : 2013-06-03
Age : 29

Re: How to map an element? | Como mapear um elemento?

on Wed Jun 05, 2013 8:33 pm
I've tried like below, is it correct?

Code:
ieDriver.get(linkFPWeb);
ieDriver.findElement(By.xpath("//div[@class='menu-bar']/span[@class=menu-button][4]/span[@class='middle']")).click();
But it didn't work, as the log says below:

Code:
org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //div[@class='menu-bar']/span[@class=menu-button][4]/span[@class='middle']
I've forgot to show, after I click the menu, I'll have to click on the sub-menu item.



This is such a nightmare...!

Sad
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Re: How to map an element? | Como mapear um elemento?

on Thu Jun 06, 2013 10:16 am
If I am not mistaken then you want to click on - "Ocorrencias"
Is there a way for me to access your application?
if you can not post application detail publicly then contact me on skype id -

tarun3kumar


_________________
Thanks
Tarun K
Free Selenium Training
avatar
Joffre
Posts : 5
Join date : 2013-06-03
Age : 29

Re: How to map an element? | Como mapear um elemento?

on Thu Jun 06, 2013 6:03 pm
I hardly think so, 'cause the application isn't mine - it is from the company I work for.

I'll try some other things here. If it doesn't work, I'll come back and try this skype option.

Thank you very much for your help so far.
Sponsored content

Re: How to map an element? | Como mapear um elemento?

Back to top
Permissions in this forum:
You cannot reply to topics in this forum