How to find element in table
Posted: Thu Dec 26, 2019 6:35 pm
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 60;
Keyboard.DefaultKeyPressTime = 30;
Delay.SpeedFactor = 1.0;
UserCodeMethods.ScrollToElement("/form[@name='ImportOprobFrm']/table[@name='PoleNameGr']/?/?/cell[@name='Fe общ.']",TestGeoTechRepository.Instance.ИмпортОпробованияШаг2Из3.PoleNameGr);
public static bool ScrollToElement(string pathToElement, Table table){
for( int i=0;i<table.Rows.Count;i++){
try{
if(Host.Local.FindSingle(pathToElement).Enabled)
{
return true;
}
}catch(ElementNotFoundException){
ScrollBar scrollBar= Таблица.FindChild<ScrollBar>();
scrollBar.FindSingle<Button>("button[@text='Down']").Click();
}
}
Report.Failure("Element'"+pathToElement+"' not founded");
return false;
}
}
method ScrollToElement recieves two parameters. firs is path to element which i am finding in table (second parametr) and it is work fine, but this code take a lot of code when i try to use it (too long line) and method is not comfortable to reuse, need path to file. i try to give this method first parameter Element (<cell>), but when test is running and element not founed, test failure with error.
{
Mouse.DefaultMoveTime = 60;
Keyboard.DefaultKeyPressTime = 30;
Delay.SpeedFactor = 1.0;
UserCodeMethods.ScrollToElement("/form[@name='ImportOprobFrm']/table[@name='PoleNameGr']/?/?/cell[@name='Fe общ.']",TestGeoTechRepository.Instance.ИмпортОпробованияШаг2Из3.PoleNameGr);
public static bool ScrollToElement(string pathToElement, Table table){
for( int i=0;i<table.Rows.Count;i++){
try{
if(Host.Local.FindSingle(pathToElement).Enabled)
{
return true;
}
}catch(ElementNotFoundException){
ScrollBar scrollBar= Таблица.FindChild<ScrollBar>();
scrollBar.FindSingle<Button>("button[@text='Down']").Click();
}
}
Report.Failure("Element'"+pathToElement+"' not founded");
return false;
}
}
method ScrollToElement recieves two parameters. firs is path to element which i am finding in table (second parametr) and it is work fine, but this code take a lot of code when i try to use it (too long line) and method is not comfortable to reuse, need path to file. i try to give this method first parameter Element (<cell>), but when test is running and element not founed, test failure with error.