Element is not clickable
Hi! I have a problem with clicking an element via Windows Application Driver. The element in the software can be clicked manually without any problem. I am aware that the Control is a Text Control but if this is the problem, is there any other way I can reach and do the click? Below you have the information of each step that I perform:
WindowsElement element; element = session.FindElementByName("LOAD PATIENT");
Result:
-
element {Element (id = 7.30408.29135036)} OpenQA.Selenium.Appium.Windows.WindowsElement
-
Coordinates {OpenQA.Selenium.Remote.RemoteCoordinates} OpenQA.Selenium.Interactions.Internal.ICoordinates {OpenQA.Selenium.Remote.RemoteCoordinates} Displayed false bool Enabled true bool Id (OpenQA.Selenium.Remote.RemoteWebElement) "7.30408.29135036" string Id "7.30408.29135036" string -
Location {X = 106 Y = 1233} System.Drawing.Point -
LocationOnScreenOnceScrolledIntoView {X = 106 Y = 1233} System.Drawing.Point OpenQA.Selenium.Internal.IWebElementReference.ElementReferenceId "7.30408.29135036" string -
Rect {X = 106 Y = 1233 Width = 188 Height = 29} System.Drawing.Rectangle Selected false bool -
Size {Width = 188 Height = 29} System.Drawing.Size TagName "ControlType.Text" string Text "LOAD PATIENT" string -
WrappedDriver {OpenQA.Selenium.Appium.Windows.WindowsDriver<OpenQA.Selenium.Appium.Windows.WindowsElement>} OpenQA.Selenium.IWebDriver {OpenQA.Selenium.Appium.Windows.WindowsDriver<OpenQA.Selenium.Appium.Windows.WindowsElement>} -
cache null System.Collections.Generic.Dictionary<string, object> -
driver {OpenQA.Selenium.Appium.Windows.WindowsDriver<OpenQA.Selenium.Appium.Windows.WindowsElement>} OpenQA.Selenium.Remote.RemoteWebDriver {OpenQA.Selenium.Appium.Windows.WindowsDriver<OpenQA.Selenium.Appium.Windows.WindowsElement>} elementId "7.30408.29135036" string -
Static members
element.Click();
Result: "An element command could not be completed because the element is not pointer - or keyboard interactable."
References: Appium.Net 4.1.1.0 SeleniumExtras.PageObjects 3.11.0.0 WebDriver 3.141.0.0
Application: WinAppDriver.exe 1.1.1809.18001-release
What's the status of the "Displayed" property when you try to click the control? Is this the only control with the name "Load Patient"? Try to wait for a few seconds before performing the click operation.
System.Threading.Thread.Sleep(5000);
If the wait helps, you can bring in intelligent wait with an object of WebDriverWait class and .Until() method.
Hi, thanks for your response, The Displayed property is set to false at the moment where I perform the Click() command. There is only one control named LOAD PATIENT. I have tried the thread.sleep() with no difference. Both before and after the execution of the FindElementByName command, but the property still stays as "false" during the Click().
There are two elements that have the Displayed property set to false. The rest of them is set to true and they all work. We will start to investigate why and I will get back to you with our findings.
Great! You found a bug :)
Hi @WinAppTester you can try hitting enter if the button to be clicked is in focus , this can be done by: element = session.FindElementByName("LOAD PATIENT"); element.sendKeys(Keys.ENTER);
Just give it a try.
Hi! Thank you for all the replies! The following solved the clicking: session.FindElementsByName("LOAD PATIENT").FirstOrDefault(e => e.Displayed).Click();
If you have problems with clicking buttons that have the text label and such declared in a grid and the actual click action is placed somewhere above in a DockPanel in the xaml code, then this method might help you.
Code extract:
// Action Click in doc panel:
<DockPanel HorizontalAlignment="{Binding ElementName=ParentGrid,
Path=DataContext.HorizontalAlignmentV}" VerticalAlignment="Center" LastChildFill="True"
MouseDown="ActionClick" Tag="{Binding Name}" Style="{StaticResource HoverDockPanelText}">
//Text object that win app driver finds with FindElement, placed inside the doc panel above:
<TextBlock Margin="10 0 10 0" TextAlignment="Center"
Style="{StaticResource HoverButtonText}" IsEnabled="{Binding IsEnabled}"
HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Path=Name,
Converter={StaticResource ToUpperConverter}}" text. TextWrapping="Wrap" Tag="{Binding Name}"/>