Closed Pranodayd closed 7 years ago
XPath locators are not supported yet. Use of x:Name
depends on the language you use to write tests.
For example in python one can simple do
from selenium.webdriver.common.by import By
By.XNAME = 'xname'
But in C# standard locators can not be extended that way, so one would something similar to implementation in https://github.com/2gis/Winium.StoreApps/blob/master/Winium/TestApp.Test/Samples/WpDriver.cs#L67
@NickAb I am using java.How can I use Xname locator strategy in Java?
I do not know for sure, but this https://mguillem.wordpress.com/2011/10/06/webdriver-subclass-the-by-class-to-define-own-locators/ might help
Hi @NickAb Can I get value of Xname property using getAttribute() function?
Yes, it should be exposed as xname
attribute
Ok.Thanks.I will try using this technique then.
@NickAb getAttribute("xname"); returning me a null. Why?Any idea?
@Pranodayd, sorry, I misread your question. What I meant is that x:Name
set in XAML can be obtained as a value of xname
attribute of XML element when using pageSource
command.
Here is the answer to you original question:
When using getAttribute
command x:Name
might be accessed using Name
property, e.g.
element.getAttribute("Name")
Note that accessing Name
property would require at least DependencyProperties
access level set in commandSettings.elementAttributeSettings.accessModifier capability, it won't be accessible if AutomationProperties
level is explicitly set. You should be all set by default if you have not specified this capability at all.
@Pranodayd where you able to find elements by x:Name
?
@NickAb Yes I could locate the element by x:Name.Thanks
Hi @NickAb . How can I use Xname element finding stratergy?Can I use xname as an attribute in Xpath? I tried using xname in xpath but didn't work. My xpath looks like this: //*[@class_name='' and @xname='']
Please help