1

I am just starting with Automatization, but I have a problem with elements.

I have this XPath

 "/Pane[@Name=\"Desktop 1\"][@ClassName=\"#32769\"]/Window[@AutomationId=\"win\"][@Name=\"COLOSSEO Show Manager 1.0.0.0 (64bit) .NET Framework 4.8.4250.0\"]/Custom[@ClassName=\"FooterView\"]/Custom[@ClassName=\"RadSplitButton\"]/Button[@AutomationId=\"ButtonPart\"][@Name=\"ButtonPart\"]/Text[@Name=\"STOP ACTIONS\"][@ClassName=\"Text\"]"

and my code is:

    [TestClass]
    public class UnitTest1
    {
        static WindowsDriver<WindowsElement> SessionApplications;

        [ClassInitialize]

        public static void BeforeTest(TestContext testContext)
        {
            AppiumOptions appiumOptions = new AppiumOptions();
            appiumOptions.AddAdditionalCapability("app", @"C:\COLOSSEO\ShowManager\Colosseo.ShowManager.exe");
            SessionApplications = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723/"), appiumOptions);
            System.Threading.Thread.Sleep(1000);
        }


        [TestMethod]
        public void TestMethod1()
        {
            SessionApplications.FindElementByName("Stop Action").Click();

But the Error is still the same:

Test Name:  TestMethod1
Test FullName:  UnitTestProject2.UnitTest1.TestMethod1
Test Source:    C:\Users\renata.cikova\source\repos\UnitTestProject2\UnitTestProject2\UnitTest1.cs : line 25
Test Outcome:   Failed
Test Duration:  0:00:00.1818331

Result StackTrace:  
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Appium.AppiumDriver`1.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
   at OpenQA.Selenium.Appium.AppiumDriver`1.FindElementByName(String name)
   at UnitTestProject2.UnitTest1.TestMethod1() in C:\Users\renata.cikova\source\repos\UnitTestProject2\UnitTestProject2\UnitTest1.cs:line 27
Result Message: 
Test method UnitTestProject2.UnitTest1.TestMethod1 threw exception: 
OpenQA.Selenium.WebDriverException: An element could not be located on the page using the given search parameters.

I don't have any idea how to find the element. Could you help me?

1
  • Most probably people will not be able to see the error without the DOM tree you running your test against. Could you provide it? – João Farias Nov 23 '20 at 21:12
1
Text[@Name=\"STOP ACTIONS\"]

FindElementByName("Stop Action")

I think you miss an S at the end. Also I think this search might be CASE SENSTIVE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.