Dynamic coding using C# - Find children
Posted: Thu Feb 12, 2015 4:20 am
Hi Team
I need to select the check boxes and radio buttons in my screen. Please refer the below code snippet.It works fine and I am selecting the checkboxes 1 after the other and also I am hardcoding in to less then or equal to 3
Code snippet 1:
******************
DivTag DTtag = webdoc.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//div[@id~'.*QuestionSetLV-body']");
for(int i=1;i<=3;i++)
{
ImgTag img = DTtag.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//tr[@id~'gridview*']//img[@src~'data:image*' and @class='x-grid-checkcolumn' and @tagname='img']");
img.Click();
}
Here, I have 2 questions.
1) I have tried the same by using "FindChildrens", however i not successful. It's always gives the count as 0. Attached code snippet 2 for your reference.
2) Is there any way to select all the checkboxes at 1 shot?
Please advise
Code snippet 2:
*****************
DivTag DTtag = webdoc.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//div[@id~'.*QuestionSetLV-body']");
ImgTag img = DTtag.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//tr[@id~'gridview*']//img[@src~'data:image*' and @class='x-grid-checkcolumn' and @tagname='img']");
IList<ImgTag> ImgChild = img.FindChildren<ImgTag>("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//tr[@id~'gridview*']//img[@src~'data:image*' and @class='x-grid-checkcolumn' and @tagname='img']");
foreach (ImgTag obj in ImgChild)
{
obj.Click();
}
I need to select the check boxes and radio buttons in my screen. Please refer the below code snippet.It works fine and I am selecting the checkboxes 1 after the other and also I am hardcoding in to less then or equal to 3
Code snippet 1:
******************
DivTag DTtag = webdoc.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//div[@id~'.*QuestionSetLV-body']");
for(int i=1;i<=3;i++)
{
ImgTag img = DTtag.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//tr[@id~'gridview*']//img[@src~'data:image*' and @class='x-grid-checkcolumn' and @tagname='img']");
img.Click();
}
Here, I have 2 questions.
1) I have tried the same by using "FindChildrens", however i not successful. It's always gives the count as 0. Attached code snippet 2 for your reference.
2) Is there any way to select all the checkboxes at 1 shot?
Please advise
Code snippet 2:
*****************
DivTag DTtag = webdoc.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//div[@id~'.*QuestionSetLV-body']");
ImgTag img = DTtag.FindSingle("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//tr[@id~'gridview*']//img[@src~'data:image*' and @class='x-grid-checkcolumn' and @tagname='img']");
IList<ImgTag> ImgChild = img.FindChildren<ImgTag>("/dom[@domain>'cvgu' and @browser~'.*Guidewire.*']//tr[@id~'gridview*']//img[@src~'data:image*' and @class='x-grid-checkcolumn' and @tagname='img']");
foreach (ImgTag obj in ImgChild)
{
obj.Click();
}