0

I am trying to create a test that will allow me to manipulate a SFGrid control. I have done this before in Selenium but it was complex and when I tried to manipulate the gird, Managing state was an issue.

I was hoping that playwrite with it's locators will allow me to identify a particular grid, and then perform actions, and verify the behaviour.

Each tab in a SFTab could contain 1 or more grids.

    <SfTab>
        <TabAnimationSettings>
            <TabAnimationPrevious Effect=AnimationEffect.None></TabAnimationPrevious>
            <TabAnimationNext Effect=AnimationEffect.None></TabAnimationNext>
        </TabAnimationSettings>
        <TabItems>
            <TabItem>
                <ChildContent>
                    <TabHeader Text="Maintain List of Courses"></TabHeader>
                </ChildContent>
                <ContentTemplate>
                    <CourseList />
                </ContentTemplate>
            </TabItem>
            <TabItem>
                <ChildContent>
                    <TabHeader Text="Maintain Course Details"></TabHeader>
                </ChildContent>
                <ContentTemplate>
                   <CourseDetails />
                </ContentTemplate>
            </TabItem>

The particular control I am trying to create a base example of is the component

    [<SfGrid @ref=CourseGrid DataSource="@availableCourses"
                   AllowPaging=true
                   Toolbar="@(new List<string>() {"Add", "Edit"})">
            <GridEvents OnActionBegin="OnActionBegin"
             TValue="CourseData"></GridEvents>
            <GridEditSettings AllowAdding=true AllowEditing=true>
                                                </GridEditSettings>
            <GridColumns>
               <GridColumn IsPrimaryKey=true AllowAdding=false AllowEditing=false 
                   Field="Key" HeaderText="Key" Width="100"> </GridColumn>
               <GridColumn Field="Title" HeaderText="Chapter Title" TextAlign=TextAlign.Left
                            </GridColumn>
            </GridColumns>
    </SfGrid>]

What I need to be able to do is navigate to the controls or headers or data without knowing what the expected content is.

When I use the playwrite inspector I get locators like these

     await Page.Locator("#sfgridxhaqtb0qdom_toolbarItems").ClickAsync();
     await Page.GetByRole(AriaRole.Button, new() { Name = "Add" }).ClickAsync();
     await Page.GetByRole(AriaRole.Gridcell, new() { Name = "ISTQB Foundation Column Header Chapter    Title" }).ClickAsync();
     await Page.Locator("div").Filter(new() { HasTextRegex = new Regex("^Chapter Title$") }).ClickAsync();

When I try to chain locators I just endup with timeouts.

ggorlen
  • 44,755
  • 7
  • 76
  • 106
Malcolm
  • 1
  • 1
  • Please share the stack trace for precise issue details. – Vishal Aggarwal May 05 '23 at 10:43
  • I eventually solved it by using GetByRole().AllAsync() and chaining those to be able to parse down in the dom var t1 = await page.page.GetByRole(AriaRole.Table).AllAsync(); Console.WriteLine(t1.Count()); var t2a = await t1[0].GetByRole(AriaRole.Row).AllAsync(); Console.WriteLine(t2a.Count()); var t3 = await t2a[0].GetByRole(AriaRole.Columnheader).AllAsync(); Console.WriteLine(t3.Count()); – Malcolm May 08 '23 at 22:46

0 Answers0