Thursday, February 6, 2025

selenium webdriver – Ingredient positioned when put in a single check case however not positioned when put in separate check case


I’m in a bizarre scenario the place I discovered that my aspect is positioned after I wrote in a single check case. However as quickly as I put that aspect in a separate check case, Unable to find aspect Exception is been given.

That is the code which isn’t working.

@Check
public void login() throws Exception {


    getdriver().get("http://10.6.6.132:3000/login");

    EyeGuide_Login_Pom lg=PageFactory.initElements(getdriver(), 
    EyeGuide_Login_Pom.class);
    lg.loginEyeguide();
    Thread.sleep(5000);
    Assert.assertEquals(getdriver().getTitle(),"EyeGuide");
    //Assert.assertEquals(getdriver().getCurrentUrl(),lg.url);
    Thread.sleep(2000);
}

@Check
public void deactivateorg() throws Exception {
    organizationpagepom or=PageFactory.initElements(getdriver(), organizationpagepom.class);
    or.deactorg();
}

}

That is the code which works as no separate check case is added.

@Check
public void login() throws Exception {


    getdriver().get("http://10.6.6.132:3000/login");

EyeGuide_Login_Pom lg=PageFactory.initElements(getdriver(), 
    EyeGuide_Login_Pom.class);
lg.loginEyeguide();
Thread.sleep(5000);
Assert.assertEquals(getdriver().getTitle(),"EyeGuide");
//Assert.assertEquals(getdriver().getCurrentUrl(),lg.url);
Thread.sleep(2000);
}


    organizationpagepom or=PageFactory.initElements(getdriver(), 
    organizationpagepom.class);
or.deactorg();


}

Beneath is the pom I’m utilizing.

public class organizationpagepom extends Basetest  {
//  organizationpagepom(WebDriver driver){
//      tremendous(driver);
//  }
@FindBy(css="a[href="https://sqa.stackexchange.com/organization"]")
WebElement manageorg;


@FindAll(@FindBy(xpath="//*[text()='Deactivate']"))
Checklist deactorglinks;
@FindAll(@FindBy(xpath="//*[@class="ant-btn downloadBtn ant-dropdown- 
    trigger"]"))
Checklist actdeactseldrpdown;
@FindAll(@FindBy(xpath="//*[@class="ant-dropdown-menu-item"]"))
Checklist activeinactiveddownvalues;


public void deactorg() throws Exception
{
    manageorg.click on();
    Thread.sleep(2000);
    deactorglinks.get(0).click on();
    Thread.sleep(2000);
    actdeactseldrpdown.get(1).click on();
    Thread.sleep(2000);
    activeinactiveddownvalues.get(0).click on();
    Thread.sleep(3000);
}

    }

EyeGuide_Login_Pom code is as follows.

public class EyeGuide_Login_Pom {



    @FindBy(title="phoneInput")
    WebElement un;
    @FindBy(xpath="//*[@placeholder="Password"]")
    WebElement pw;
    @FindBy(css="button[type="button"]")
    WebElement signinbtn;


    public void loginEyeguide() 
    {
        un.clear();
        un.sendKeys("tdladmin");
        pw.sendKeys("tremendous");
        signinbtn.click on();

    }



}

I’ve taken the WebDriver object as non-public and I used getdriver() methodology to entry the non-public variable. I do not know why this subject is been popped out.
The code of WebDriver entry is as follows.

public class Basetest {
    non-public WebDriver driver;


    @BeforeTest
    public void setbrowserproperties()
    {
        System.setProperty("webdriver.chrome.driver","F:Browser Chrome Driver recordsdatachromedriver.exe");
        this.driver=new ChromeDriver();
        getdriver().handle().window().maximize();
    }

    @AfterTest
    public void closedriver()
    {
        getdriver().shut();
    }
    protected WebDriver getdriver() {
        return driver;
    }

}

Please assist me as I’m not capable of finding any answer. Beneath is the error that I get.

org.openqa.selenium.NoSuchElementException: no such aspect: Unable to find aspect: {"methodology":"css selector","selector":"a[href="https://sqa.stackexchange.com/organization"]"}

Replace: I additionally tried this nevertheless it did not work and did not give me any failure.

public organizationpagepom oged() throws Exception {    
    //getdriver().handle().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
    organizationpagepom oot=PageFactory.initElements(getdriver(), organizationpagepom.class); 
    oot.deactorg(); 
    return oot; 
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

PHP Code Snippets Powered By : XYZScripts.com