Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
Joffre
Joffre
Posts : 5
Join date : 2013-06-03
Age : 35

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

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:

How to map an element? | Como mapear um elemento? Menu
menu.jpg

How to map an element? | Como mapear um elemento? Html
html.jpg
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

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

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.
Joffre
Joffre
Posts : 5
Join date : 2013-06-03
Age : 35

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

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.

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

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)
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

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

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.
Joffre
Joffre
Posts : 5
Join date : 2013-06-03
Age : 35

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

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.

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

This is such a nightmare...!

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

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

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

Joffre
Joffre
Posts : 5
Join date : 2013-06-03
Age : 35

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

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

How to map an element? | Como mapear um elemento? Empty 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