(name, verb, command string, params interface{})
| 804 | } |
| 805 | |
| 806 | func (wd *remoteWD) modifyWindow(name, verb, command string, params interface{}) error { |
| 807 | // The original protocol allowed for maximizing any named window. The W3C |
| 808 | // specification only allows the current window be be modified. Emulate the |
| 809 | // previous behavior by switching to the target window, maximizing the |
| 810 | // current window, and switching back to the original window. |
| 811 | var startWindow string |
| 812 | if name != "" && wd.w3cCompatible { |
| 813 | var err error |
| 814 | startWindow, err = wd.CurrentWindowHandle() |
| 815 | if err != nil { |
| 816 | return err |
| 817 | } |
| 818 | if name != startWindow { |
| 819 | if err := wd.SwitchWindow(name); err != nil { |
| 820 | return err |
| 821 | } |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | url := wd.requestURL("/session/%s/window", wd.id) |
| 826 | if command != "" { |
| 827 | if wd.w3cCompatible { |
| 828 | url = wd.requestURL("/session/%s/window/%s", wd.id, command) |
| 829 | } else { |
| 830 | url = wd.requestURL("/session/%s/window/%s/%s", wd.id, name, command) |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | var data []byte |
| 835 | if params != nil { |
| 836 | var err error |
| 837 | if data, err = json.Marshal(params); err != nil { |
| 838 | return err |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | if _, err := wd.execute(verb, url, data); err != nil { |
| 843 | return err |
| 844 | } |
| 845 | |
| 846 | // TODO(minusnine): add a test for switching back to the original window. |
| 847 | if name != startWindow && wd.w3cCompatible { |
| 848 | if err := wd.SwitchWindow(startWindow); err != nil { |
| 849 | return err |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | return nil |
| 854 | } |
| 855 | |
| 856 | func (wd *remoteWD) ResizeWindow(name string, width, height int) error { |
| 857 | if !wd.w3cCompatible { |
no test coverage detected