0

Try to test some Fields and when i check "Inspect element" to identify id or name of Fields but there was only class that didn't work so i decided to use XPath for example:

$I->fillField('/html/body/div/form/div[2]/div[3]/div/div[1]/label/span[1]','GRV');

And gets Failures and Error:

1) Couldn't sign in in Authorization  
Ups, I couldn't fill field "/html/body/div/form/div[2]/div[3]/div/div[1]/label/s
pan[1]","blabla",
Field by name, label, CSS or XPath '/html/body/div/form/div[2]/div[3]/div/div[1]
/label/span[1]' was not found on page.

I checked few times XPath, can't test this fields. It would be great if you tell what a problem and how to solved it.

2 Answers2

0

You try to fill a label, not the input element:

//label/span[1]

Make sure to select the input field you want to fill instead. Look for an <input id="foo"/> if your label has an for-attribute with value "foo".

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
  • Nope, i just made mistake in example xpath. Really, i'm looking for xapth like '//span/input[1]' Anyway, codeception generates message like Unable to locate element: {"method":"xpath","selector":"//html"} – Yura Reznik Aug 28 '13 at 13:53
  • I think that's exactly what I'm writing about. How does your HTML look like? – Jens Erat Aug 28 '13 at 16:30
0

Well, avoid usage of this kind of XPaths. It's really toooo loooong. You just break your mind and ours too trying to solve it :) Just add #id selector to the element you are matching and be happy.

The test with such XPath will break on every markup change of your page. Why would you need a test that is such hard to maintain?

Davert
  • 314
  • 1
  • 5
  • Of course we can add #id selector to the elements but this will be the last option. We try to test with long and short "//" XPath, both didn't work. Despite the fact that Codeception must test with XPath also very well, so where is the problem and how to solved with XPath. – Yura Reznik Sep 02 '13 at 12:22