16.5 C
New York
Sunday, October 20, 2024

selenium webdriver – Factor is just not identifed within the second check methodology


I’ve an odd habits : I created Take a look at Class with 2 Take a look at Strategies as under.

After I name AddLimitedBuyOrderwithRandom within the first methodology it really works tremendous with none exception, but when I name AddLimitedBuyOrderwithRandom from the second methodology I get a NoSuchElement exception.

That is the code for the check class:

public class TestLoginPage extends TestBase {
    public HomePage homeobject;
    public NewOrdersLoginPage OrderLoginObject;
    public OrderMgmtPage OrdersMgmentObject;

    @Take a look at
    public void SuccessLogin() throws InterruptedException
    {
        homeobject = new HomePage(driver);
        homeobject.OpenOrdersPage();
        OrderLoginObject = new NewOrdersLoginPage(driver);
        OrderLoginObject.userLogin("140", "12345");
        OrdersMgmentObject = new OrderMgmtPage(driver);
        OrdersMgmentObject.AddLimitedBuyOrderwithRandom("10");
    }

    @Take a look at(enabled= true)
    public void AddLimitOrderTest() throws InterruptedException
    {
        OrdersMgmentObject = new OrderMgmtPage(driver);
        OrdersMgmentObject.AddLimitedBuyOrderwithRandom("10");
    }   
}

and that is the code for AddLimitedBuyOrderwithRandom:

public void AddLimitedBuyOrderwithRandom(String SharesCount) throws InterruptedException
{  
    clickButton(NewOrderLink);
    clickButton(BuyTypeRadio);
    selectDropdownByValue( companyList, "Firm");
    typeText(ShareNoTxt, SharesCount);
    selectDropdownByValue(  OrderTypeList, "2");
    selectDropdownByValue( OrderValidityList, "0");
    double Pricerandom = getRandomNumberInRange(ReturnShareLimitDown(),ReturnShareLimitUp());
    typeText(SharePriceTxt,Double.toString(Pricerandom));
    clickButton(SubmitOrderBtn);    
} 

(Added from feedback on solutions)
My base class is:

public class TestBase 
{ 
    public static WebDriver driver ; 
    public static String downloadPath = System.getProperty("person.dir") + "Downloads"; 
    public String BaseURL = "URL"; 

    @BeforeSuite 
    @Parameters({"browser"}) 
    public void startDriver(@Non-obligatory ("chrome") String browserType) 
    { 
        if (browserType.equalsIgnoreCase("chrome") ) 
        { 
            System.setProperty("webdriver.chrome.driver", System.getProperty("person.dir")+"/drivers/chromedriver.exe"); 
            driver = new ChromeDriver(); 
        } 
    } 
    
    driver.handle().window().maximize(); 
    driver.navigate().to(BaseURL); 
} 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles