Hi Emily, I am not a PHP coder, so I can't help you much here.
However, a couple of thoughts.
I assume you are using WebDriver.execute($script,$script_args).
According to the documentation, WebDriver creates an anonymous
javascript function, and the $script_args variable is transformed
into a local array within that function called "arguments" and your
javascript script can use the "arguments" variable in the code. NOTE:
The first argument can be accessed in javascript as "arguments[0]",
the second argument can be accessed as "arguments[1]", etc…
Also, according to the documentation, you can pass in as arguments any
primitive data type (int, string, float, etc…) and , most importantly,
you can pass in a WebElement object. When a WebElement object is
passed in, it is transformed into the corresponding DOM element.
So, even though the "WebElement" object does not have a "setAttribute"
method, once the WebElement has been converted into a DOM element the
javascript engine does have a "setAttribute" method.
So, in essence, if I tell WebDriver to execute the following
javascipt : "arguments[0].setAttribute(arguments[1],arguments[2]);"
and I pass in as arguments a WebElement that I previously found (by
using WebDriver.findElement) and two strings, the Javascript will
properly set the attribute on the DOM element.
Hope that helps. If not, send the errors you keep getting and the
script you are passing in.