- vidya shreeRegular Participant
- Posts : 31
Join date : 2013-05-09
Problems in locating elements in Selenium
Thu May 09, 2013 4:45 pm
Hi!! I m new to Selenium. i am using Selenium 2.0 (java).I am facing problms in locating the elements.
For example:
I tried to locate "Logout" in the mail by id,Xpath and CSS.But none of this located properly.
Even i checked using Firefinder to highlight that Element(Logout) by Xpath and CSS.But i cudnt find it.
Please help me to clear out the issue.
[ Does selenium has any Object Repository as in QTP ??..
Selenium looks difficult in locating objects when compare to QTP.Is it so?
Which is the best tool for Automation Testing?? ]
Looking forward ur kindness.
Thanks,
Vidya.
For example:
I tried to locate "Logout" in the mail by id,Xpath and CSS.But none of this located properly.
Even i checked using Firefinder to highlight that Element(Logout) by Xpath and CSS.But i cudnt find it.
Please help me to clear out the issue.
[ Does selenium has any Object Repository as in QTP ??..
Selenium looks difficult in locating objects when compare to QTP.Is it so?
Which is the best tool for Automation Testing?? ]
Looking forward ur kindness.
Thanks,
Vidya.
Re: Problems in locating elements in Selenium
Thu May 09, 2013 5:23 pm
Selenium does not have object repo like QTP, but nothing stops you to build one. About Logout link, would you show us html of link and locator you used?
- vidya shreeRegular Participant
- Posts : 31
Join date : 2013-05-09
Re: Problems in locating elements in Selenium
Thu May 09, 2013 5:48 pm
Thanks for ur response
Following is the HTML for t same.
"id="e-toptoolbar-pref" class="s-top-text" onclick="AAA.DSq.ELU(event, this.id, 'EPH');return false;" style="font-weight: bold;" href="#">Logout"
Note: I ve removed the anchor tag in the above code.
For tat i ve used xpath as "//*[@id="e-toptoolbar-pref"]" and "//html/body/div/div/div[6]/div/table/tbody/tr/td[7]/a"
and CSS as "html body.s-basicpanel div.s-stack div.s-basicpanel div.s-toppanel div#e-mainmenu-area.s-mainmenu-area table.s-top-text tbody tr td a#e-toptoolbar-pref.s-top-text"
Awaiting ur response
Thanks
Vidya
Following is the HTML for t same.
"id="e-toptoolbar-pref" class="s-top-text" onclick="AAA.DSq.ELU(event, this.id, 'EPH');return false;" style="font-weight: bold;" href="#">Logout"
Note: I ve removed the anchor tag in the above code.
For tat i ve used xpath as "//*[@id="e-toptoolbar-pref"]" and "//html/body/div/div/div[6]/div/table/tbody/tr/td[7]/a"
and CSS as "html body.s-basicpanel div.s-stack div.s-basicpanel div.s-toppanel div#e-mainmenu-area.s-mainmenu-area table.s-top-text tbody tr td a#e-toptoolbar-pref.s-top-text"
Awaiting ur response
Thanks
Vidya
- vinayakjadhav1857Active particpant
- Posts : 19
Join date : 2013-04-22
Re: Problems in locating elements in Selenium
Thu May 09, 2013 6:42 pm
will u show the whole html code or the relative div ?
- vidya shreeRegular Participant
- Posts : 31
Join date : 2013-05-09
Re: Problems in locating elements in Selenium
Thu May 09, 2013 8:32 pm
Thanks for ur response vinayak
I am not able to attach my code here.
Any suggestions to display the code ??
Thanks,
Vidya.
I am not able to attach my code here.
Any suggestions to display the code ??
Thanks,
Vidya.
- vinayakjadhav1857Active particpant
- Posts : 19
Join date : 2013-04-22
Re: Problems in locating elements in Selenium
Fri May 10, 2013 11:23 am
ok.. just check in which frame ""e-toptoolbar-pref" " is located in your plain HTML code..switch to that frame..and then select the respective element..
driver.switchTo().frame("yourframename");
driver.switchTo().frame("yourframename");
- vidya shreeRegular Participant
- Posts : 31
Join date : 2013-05-09
Re: Problems in locating elements in Selenium
Fri May 10, 2013 12:29 pm
Thanks for ur response vinayak
Ya Its working now.
Now i am able to locate the logout link.
Here is my code:
driver.switchTo().frame(driver.findElement(By.name("s_MainFrame")));
WebElement logout = driver.findElement(By.xpath("//html/body/div/div/div[6]/div/table/tbody/tr/td[7]/a"));
logout.click();
driver.switchTo().defaultContent();
Thanks again.
Vidya.
Ya Its working now.
Now i am able to locate the logout link.
Here is my code:
driver.switchTo().frame(driver.findElement(By.name("s_MainFrame")));
WebElement logout = driver.findElement(By.xpath("//html/body/div/div/div[6]/div/table/tbody/tr/td[7]/a"));
logout.click();
driver.switchTo().defaultContent();
Thanks again.
Vidya.
- vinayakjadhav1857Active particpant
- Posts : 19
Join date : 2013-04-22
Re: Problems in locating elements in Selenium
Fri May 10, 2013 1:01 pm
nice to hear..
Permissions in this forum:
You cannot reply to topics in this forum
|
|