I think we need this only before `$element->postValue(array('value' => str_split($path)));` line.

Other called methods, like `attachFile` or `selectOption` should take care of type casing themselves, since they can be called on their own and should not fail if integer is given.