I need to write a custom function to populate an email input field with a unique email address. But the page has dynamically-generated IDs, so I can't just use $page->find()
to easily grab the elements. How do I grab the input element by its name?
public function iFillInUniqueEmail($arg1)
{
$page = $this->getSession()->getPage();
$element = $page->find('css', $arg1);
if (null === $element) {
throw new InvalidArgumentException(sprintf('Could not evaluate CSS selector: "%s"', $arg1));
}
$date = date('YmdHis');
$email = "test" . $date . "@test.com";
$element->setValue($email);
}
You can find element by name
attribute like this:
$el = $page->find('css', 'input[name="input_name_goes_here"]');