Search code examples
phpxpathphpunitcodeception

Codeception - Xpath in PHPBrowser and Array Fields


This is sort of a 2 part question:

I'm using Codeception to test some Codeigniter code. Just using Acceptance testing. Lets say you have a field like:

<input type='text' name='materials[]' />

I've found that I have trouble filling this field using fillfield('materials[]', 'some value');. It seems that fillfield() doesn't know what to do with the brackets

So from there, I figured I'd use Xpath instead of the input name, and avoid the brackets all together. However, no matter what Xpath I try, the test always fails. I've confirmed that the Xpaths work by using the Chrome console, but those same paths seem to fail in Codeception.

So my question is: has anyone successfully dealt with array inputs in Codeception PhpBrowser, and how? And has anyone successfully used Xpath in Codeception with PhpBrowser? If so, is there perhaps a format, or escape character that needs to be accounted for when using Xpaths in Codeception?


Solution

  • I was using an older version of Codeception (1.8) which wasn't compatible with Xpaths. Codeception 2, however, seem to function with XPaths.