-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fireEvent new command #130
Comments
I did a cursory google search and saw some results from 2009/2010 referring to selenium RC? I didn't see anything about it in the JSONWireProtocol document. It does sound quite useful though so it would be nice if it were an up and coming change... |
I had a deeper look in the java client code and in the file |
Selenium package is now using some javascript libraries to execute commands like fireEvent. |
Is fireEvent.js is automatically loaded/included with the standalone server? What did your
Making an assumption or two, in WebElement.pm, a suite of event functions that look something like sub blur {
my ($self) = @_;
return $self->execute_script('return ("fireEvent.js").apply(null, arguments);', $self, 'blur');
} with usage like my $elem = $driver->find_element('unique', 'id');
$elem->blur; ??? (oh and hmm we'd need to update WebElement's |
The file fireEvent.js is used for multiple purpose $driver->fire_event('id=unique', 'blur') So fire_event could look like sub fire_event {
my ($self, @args) = @_ ;
my $script = this->_some_function_to_retreive_js_file('fireEvent.js') ;
return this->execute_script("return (" . $script . ").apply(null, arguments);", @args) ;
} The fireEvent.js script is built during the compilation of the selenium-sources package (client and server side). In the java client, it is built in a library file so using some "getResource" function will find the file and load it... |
Would you mind providing a few links to the references where you found this stuff? Feeling a bit lazy about digging through docs at the moment :) On different note, do you know if there are events that we want to fire against the entire page, ie, not against a particular element? If the events are always fired against elements, I think they'd fit better in the WebElement class instead of on the Driver - it's more consistent with the rest of the 'element only' actions being on WebElement.. |
Sorry for the delay, You may download the selenium-standalone version from git : About implementation, I think it should be one of Driver's methods. About events that could be sent on the entire page, I'm not sure. What I have seen so far, is events like 'rotate', 'shake', 'tap or double tap', etc... all events what comes with devices like phones. |
I do have a problem with the result type of _execute_command. So is it possible to change the return value of _execute_command to check if the caller wants an array : return $resp->{cmd_return}; should by replaced by return wantarray ? ($resp->{cmd_status}, $resp->{cmd_return}) : $resp->{cmd_return}; The execute_script should also be adapted : my $ret = $self->_execute_command( $res, $params );
return $self->_convert_to_webelement($ret) ; could be replaced by my @ret = $self->_execute_command( $res, $params );
return wantarray ? ($ret[0], $self->_convert_to_webelement($ret[1])) :
$self->_convert_to_webelement($ret[1]) ; here the diff :
Let me know what you think about it |
Any comment on my proposal ? |
Hm, it does seem to be directly related to #135 - the return value of I'm reluctant to change the behavior of
which would imply that getting back undef from your executed script can?/should? be interpreted as success. That being said, things get a lot more complicated, especially with execute_script, so. I'm not really sure. |
It sounds like this is a javascript extension to the selenium RC; as such this should probably be implemented as a convenience wrapper around execute_script(), rather than fiddling with something fundamental like execute_script. There are actually a wide variety of JS convenience methods what should probably be added to the module (such as waiting on events to fire, which is the only real way to conquer race conditions). |
Since recently, there is a new command in the selenium command list : fireEvent
fireEvent id=searchq blurHere is an extract from a script :
It is used to simulate events on some fields.
Does anyone had a look on it and how to implement it in perl ?
I had a look in selenium server the sources, it seems to be translated in a javascript that find the element and send the event on it. something like
document.getElementById('foobar').onblur();
Any idea what has to be sent to the server ?
The text was updated successfully, but these errors were encountered: