Unable to move/rename tests without breaking coded references to elements

2 posts, 0 answers
  1. Nick
    Nick avatar
    23 posts
    Member since:
    Nov 2013

    Posted 12 May 2014 Link to this post

    I have one test that was used to record many actions and elements in a silverlight application using TS/VS2012.  This was the very first test I ever recorded and is no longer needed/fits into the evolution of our test suite.  I want to either delete, move or rename the test to clean up our project, but doing so breaks many coded references to the elements that were recorded as part of that test.

    - If I delete the test, all the elements recorded in that particular test are deleted as well, which breaks any coded references to the elements that were recorded in that same test.  
    - If I move the test to another folder, all of the coded references to the recorded elements are broken and the below error is triggered.  
    - If I rename the folder containing the tests to something else, all of the coded references to the recorded elements are broken and the below error is triggered.

    Error:
    'TestProject.Pages.TestPage.SilverlightAppElement' does not contain a definition for 'LoginButton' and no extension method 'LoginButton' accepting a first argument of type 'TestProject.Pages.TestPage.SilverlightAppElement' could be found (are you missing a using directive or an assembly reference?)

    For example, the above error is triggered when the below line of code is used in a coded step of another test, OR when used in common/utility class, and the original test is moved, deleted or renamed:
    Pages.TestPage.SilverlightApp.LoginButton.User.Click();

    Is there any way to move/rename or delete the original test without breaking the link between coded steps and the original elements?

    Steps to reproduce:
    1. Create a new project using VS
    2. Record a simple test of navigating to google and typing "test", name it Test1
    3. Create another test, add a basic coded step to click search (Pages.Google.Search.User.Click()), name it Test2
    4. Rename Test1 to xTest1
    5. Rebuild the project and note the error that is displayed




  2. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 15 May 2014 Link to this post

    Hello Nick,

    No repro given the steps you outlined as demonstrated in this video:
    http://screencast.com/t/0Hj3Fj2J

    You're right in that if you delete a test that is holding the elements referenced by coded step in another test, it will cause compile failures. My suggestion in such a case is to copy the element definition out of the Pages.g.cs file before you delete the test and manually add it to coded step of test 2. You won't use Pages.PageName.Element format, but use your own code once you've extracted it out of Pages.g.cs.

    For the problem you're having with renaming a test or moving it into another folder, can you send us a project that exhibits this behavior for us to study?

    Regards,
    Cody
    Telerik
     
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
     
Back to Top