Function: Enforce login for login account, use if to determine whether the current account is available. If available, then jump out of the if body directly login, if not available, then enter if body click the "force Login" button.
Issue: If not available, the object in the if condition is not visible, and the program throws an error #1009 (unable to access the property or method of the null object reference).
Handling method: The IF statement is placed in the try catch to handle the exception error.
// CLIKC login button login.loginbutton.locator.click (); // force longin Pause (1000 try { if (login.ok.locator.visible) { login.ok.locator.click (); Pause ( 2000);
Login.forcedLogin.locator.click (); Pause ( 4000); Login.ok_forced.locator.click (); Pause ( 2000); Login.loginButton.locator.click ();} catch (E) {Pause ( 1000);} Pause ( 20000);
RIA test:try catch handling of Error #1009 (properties or methods that cannot access a null object reference)