views:

6

answers:

0

Hi all,

i am writing a test case which causes page redirection while looping between rows in a table... Here is my code -

public void dashboardprivatefunctionality() { TableBodyCollection pbody = ieinstance.Table(Find.ByClass("GridStyle1")).TableBodies; foreach (var tb in pbody) { //int o = tb.TableRows.Count; foreach (var trows in tb.TableRows) { String rowstyle = trows.Style.BackgroundColor.ToName.ToString();

                foreach (var tcell in trows.TableCells)
                {
                    Button pdetail = tcell.Button(b => b.Value == "Detail");
                    if (pdetail.Exists)
                    {

                        pdetail.Click();
                        Span pinfo = ieinstance.Span(s => s.ClassName == "Icon8");
                        if (pinfo.Exists)
                        {
                            Link a = (Link)pinfo.Parent;
                            a.Click();
                            Thread.Sleep(5000);
                            CheckBox pcheckbox = ieinstance.CheckBox(c => c.Name == "IsPrivate");
                            bool presult = pcheckbox.Checked;
                            if (presult == true)
                            {
                                Assert.AreEqual("Red", rowstyle);
                            }
                            Link homepage = ieinstance.Link(l => l.Text == "Dashboard");
                            homepage.Click();
                            Thread.Sleep(5000);

                        }


                    }


                }


            }
        }

    }

What i need is to retain object of which is at top. i loose it due to page redirection at "pdetail.click". Please reply asap...