In case of the App window is fully covered by other window, find_element_by_id(“xxx”).click() is not working. Is there any method to set the target window to top-most?
Use the SwitchTo method call on your driver/session object.
AppiumOptions options = new AppiumOptions();
options.AddAdditionalCapability("app", @"Excel");
options.AddAdditionalCapability("deviceName", "WindowsPC");
_driver = new WindowsDriver(new Uri("http://127.0.0.1:4723"), options);
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
_driver.SwitchTo().Window(_driver.WindowHandles.First());
In my python code, I can't find SwitchTo function.
self.desired_caps = {}
self.desired_caps["app"] = "Root"
self.root = webdriver.Remote(command_executor='http://127.0.0.1:4723', desired_capabilities=self.desired_caps)
I want to bring "My Program" to top-most.
But I can't find the related methods you mentioned in self.driver (switch_to and windowhandles.first()).
In self.root I can find the switch_to method, but it seems not work.
self.root.switch_to.window(self.root.window_handles….) : X , do not have First() func
self.driver.switch_to : X, do not have switch_to func
Yes you will not have the first function in python, you need to switch using index 0.
@tigerphc, were you able to resolve this?
I tried that in C#:
_driver.SwitchTo().Window(_driver.WindowHandles.First());
The _driver.WindowHandles contains only one entry, and it matches my application 100%, VisualStudio stays on top of my desktop though.
So far nothing proves useful in this case.
Most helpful comment
I tried that in C#:
_driver.SwitchTo().Window(_driver.WindowHandles.First());The
_driver.WindowHandlescontains only one entry, and it matches my application 100%, VisualStudio stays on top of my desktop though.So far nothing proves useful in this case.