How to handle when there is no element on /td[3] ,since there is an uncertain delay to get the innertext,
now getting error on- _psld=elem.innertext -- Object reference not set to an instance of an object.
I don't get the error when there is an innertext,
WebElement elem = "/dom[@caption='xxProfile']//div[@id='flashRoot_1']/table[2]/tbody/tr/td[1]/table[1]/tbody/tr[3]/td[1]/table/tbody/tr[10]/td[3]";
_psId = elem.InnerText;
------
here is the full code
public string CopyId()
{
int counter =0;
_psId = " ";
while(_psId ==" ")
{
WebDocument web = "/dom[@caption='xxProfile']";
web.EnsureVisible();
Delay.Ms(20000);
Keyboard.Press("{F5}");
Delay.Ms(20000);
WebElement elem = "/dom[@caption='xxProfile'Profile']//div[@id='flashRoot_1']/table[2]/tbody/tr/td[1]/table[1]/tbody/tr[3]/td[1]/table/tbody/tr[10]/td[3]";
_psId = elem.InnerText.Trim(); //getting Error when there is no innertext-Object reference not set to an instance of an object
counter = counter+1;
if (counter==5)
_psId ="NotFound";
break;
}
}
}
Thank you in Advance
elem.innertext
Re: elem.innertext
Put a try/catch block in. Catch and deal with the exception if it occurs.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!
Ciege...
Ciege...