MCPcopy Create free account
hub / github.com/tebeka/selenium / modifyWindow

Method modifyWindow

remote.go:806–854  ·  view source on GitHub ↗
(name, verb, command string, params interface{})

Source from the content-addressed store, hash-verified

804}
805
806func (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
856func (wd *remoteWD) ResizeWindow(name string, width, height int) error {
857 if !wd.w3cCompatible {

Callers 4

CloseWindowMethod · 0.95
MaximizeWindowMethod · 0.95
MinimizeWindowMethod · 0.95
ResizeWindowMethod · 0.95

Calls 4

CurrentWindowHandleMethod · 0.95
SwitchWindowMethod · 0.95
requestURLMethod · 0.95
executeMethod · 0.95

Tested by

no test coverage detected