Hi,
I was trying to look for a Kendo Menu to click on using C# code but I keep hitting error "System.NullReferenceException: Object reference not set to an instance of an object."
The DOM where the element is located is as per the attached image.
I tried using the element reference from Element Repository to perform actions but I keep hitting error:
1.
Pages.Home.Menu_Setup.MouseHover(0, 0, ArtOfTest.Common.OffsetReference.AbsoluteCenter);
2.
Pages.Home.Menu_Setup_Contract.MouseHover(0, 0, ArtOfTest.Common.OffsetReference.AbsoluteCenter);
3.
Pages.Home.Menu_Setup_Contract_MasterPriceList.Click(
false
);
Failure Information:
~~~~~~~~~~~~~~~
Exception thrown executing coded step:
'[Coded_Master_Price_List_CodedStep1] : Master Price List Entry'
.
InnerException:
System.ArgumentException: Invalid tag name
'span'
for
this
control. Control was expecting
'li'
Then the code is amended based on the documentation here to try looking for the element's parents and perform clicking:
1.
IList<KendoMenuItem> itemList = ActiveBrowser.Find.AllByAttributes<KendoMenuItem>(
"role=menuitem"
);
2.
HtmlFindExpression li =
new
HtmlFindExpression(
"title=SETUP"
,
"innertext=~Setup"
);
3.
li.AddHierarchyConstraint(
new
HierarchyConstraint(
new
HtmlFindExpression(
"role=menuitem"
), -1));
4.
KendoMenuItem menuSetup = Find.ByExpression<KendoMenuItem>(li);
5.
menuSetup.Click();
Then the error is hit:
Failure Information:
~~~~~~~~~~~~~~~
Exception thrown executing coded step:
'[Coded_Master_Price_List_CodedStep1] : Master Price List Entry'
.
InnerException:
System.NullReferenceException: Object reference not
set
to an instance of an
object
.
Can I please ask for help on which part is wrong in this code?
Thank you.