@@ -36,55 +36,15 @@ bool MoveAndClickCommand::DoesPost() {
3636}
3737
3838void MoveAndClickCommand::ExecutePost (Response* response) {
39- std::string tag_name;
40- Error* error = session_->GetElementTagName (
41- session_->current_target (), element, &tag_name);
42- if (error) {
43- response->SetError (error);
44- return ;
45- }
39+ Error* error = NULL ;
40+
41+ error = session_->MoveAndClickElement (session_->current_target (), element);
4642
47- if (tag_name == " option" ) {
48- const char * kCanOptionBeToggledScript =
49- " function(option) {"
50- " for (var parent = option.parentElement;"
51- " parent;"
52- " parent = parent.parentElement) {"
53- " if (parent.tagName.toLowerCase() == 'select') {"
54- " return parent.multiple;"
55- " }"
56- " }"
57- " throw new Error('Option element is not in a select');"
58- " }" ;
59- bool can_be_toggled;
60- error = session_->ExecuteScriptAndParse (
61- session_->current_target (),
62- kCanOptionBeToggledScript ,
63- " canOptionBeToggled" ,
64- CreateListValueFrom (element),
65- CreateDirectValueParser (&can_be_toggled));
6643 if (error) {
6744 response->SetError (error);
68- return ;
6945 }
7046
71- if (can_be_toggled) {
72- error = session_->ToggleOptionElement (
73- session_->current_target (), element);
74- } else {
75- error = session_->SetOptionElementSelected (
76- session_->current_target (), element, true );
77- }
78- } else {
79- Point location;
80- error = session_->GetClickableLocation (element, &location);
81- if (!error)
82- error = session_->MouseMoveAndClick (location, automation::kLeftButton );
83- }
84- if (error) {
85- response->SetError (error);
8647 return ;
87- }
8848}
8949
9050HoverCommand::HoverCommand (const std::vector<std::string>& path_segments,
0 commit comments