- r2bhasin
- Posts : 2
Join date : 2012-05-31
Just starting - Object identification help
Mon Oct 15, 2012 4:27 pm
Hi guys,
I've just written my first Sel Webdriver script in ruby and am trying to run it, it doesn't seem to be recognizing the object i need to verify.
I've copied the xpath of the object i need to verify from Firebug and written the code below -
_____________________________________________
myn = driver.find_element(:xpath, "/html/body/div/div[2]/div/section/div/div/header/div/h1")
if myn == "Welcome to myn" then
puts "yes"
else
puts "no"
end
_____________________________________________
I would expect it to print yes but it prints no, so i think it is not recognising the object correctly. I suspect i'm not using it correctly maybe, please help??
Also, is it possible to verify that a certain xpath or CSS will identify the object without running the script(like in QTP we have Highlight object in application in the OR)??
I've just written my first Sel Webdriver script in ruby and am trying to run it, it doesn't seem to be recognizing the object i need to verify.
I've copied the xpath of the object i need to verify from Firebug and written the code below -
_____________________________________________
myn = driver.find_element(:xpath, "/html/body/div/div[2]/div/section/div/div/header/div/h1")
if myn == "Welcome to myn" then
puts "yes"
else
puts "no"
end
_____________________________________________
I would expect it to print yes but it prints no, so i think it is not recognising the object correctly. I suspect i'm not using it correctly maybe, please help??
Also, is it possible to verify that a certain xpath or CSS will identify the object without running the script(like in QTP we have Highlight object in application in the OR)??
- rohit kumar guptaActive particpant
- Posts : 24
Join date : 2012-09-19
Age : 34
Location : abc
Re: Just starting - Object identification help
Sun Oct 21, 2012 6:09 pm
Hi,
In order to identify, Find button of selenium ide can be a workaround.
Second thing findelement will return you the handle of the object and you are trying to compare it to a string.
** to resolve this you can try this
int i=myn.getText().compareto("what you expect");
if i=0 then it matches....
In order to identify, Find button of selenium ide can be a workaround.
Second thing findelement will return you the handle of the object and you are trying to compare it to a string.
** to resolve this you can try this
int i=myn.getText().compareto("what you expect");
if i=0 then it matches....
Permissions in this forum:
You cannot reply to topics in this forum