1

I have a functional button but it has no identifier. Now how can I catch that button from my web application which has no Identifier. I am using Ride as an Editor.

mfuad
  • 11
  • 2
  • Welcome to Stack Overflow! Could you explain what your problem is in further detail? – Simon Nov 17 '14 at 08:42
  • thanks your prompt response.I am trying to write a script in Ride.For this i am writing some keywords but in one place in my application, i found there is no Id or value for a field. Now how can i catch this field. for example: i have a drop down list named from where i will select any value but when i open with firebug then i can not find any id. Is there any way to catch this id(preferable any css locator). – mfuad Nov 17 '14 at 09:19

1 Answers1

0

When you have no ID or VALUE to locate an element, you can try to use XPATH (every element has one). The way to use it is explained in the Selenium2Library doc (assuming you are using this one). It might be brittle because when organisation of the page change, your xpath change, but this is a good workaround. You would do something like:

Click Element  xpath=//*[@id="menu"]/ul/li[2]/a/span[2]

Now to find the XPath itself, I would recommend to use Chrome Dev Tools (see this great video). This is also discussed in another SO thread.

Community
  • 1
  • 1
Laurent Bristiel
  • 6,270
  • 29
  • 51
  • Thanks for your answer.I have an xpath and this is:/html/body/table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]/a[4]/img.Now what will be the syntax? Is it: Click Element xpath = //*[@id="menu"]//html/body/table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]/a[4]/img – mfuad Nov 19 '14 at 08:49
  • yes Click Element xpath=//*[@id="menu"]//html/body/table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]/a[4]/img (beware the spaces) – Laurent Bristiel Nov 19 '14 at 08:58
  • I tried and executed but it says xpath ---- not found. Thanks – mfuad Nov 19 '14 at 09:47
  • sorry, I read too fast your comment. Try this: Click Element xpath=/html/body/table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]/a[‌​4]/img – Laurent Bristiel Nov 19 '14 at 09:49
  • thanks. But doesn't work.same message "xpath not found". Since it is an image button, is there any way to catch this button with CSS locator. – mfuad Nov 19 '14 at 10:41
  • try xpath=html/body/table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]/a[‌​4]/img – Laurent Bristiel Nov 19 '14 at 10:44
  • I can catch this button with "xpath=//html/body/form/div[1]/table/tbody/tr[4]/td/table/tbody/tr/td/input" but when i try to catch this: "xpath=//html/body/table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]/a[4]/img", i can not.System says xpath not found.But my main concern was is there any css command in RobotFramework by which i can catch an image, for ex: . I want to catch this button. Any help from anyone? – mfuad Nov 20 '14 at 04:24