I cannot find elements that I want to interreact with on any page other than the main page. The electron app I am working with has several that load with the start of the app but I am only able to access the elements on the first page. I think there must be an error in how I switch pages because I am confident in how I am looking for elements. The segment of code that changes page and looks for element is below.
var mainhandle = await driver.getWindowHandle();
var windowhandles =await driver.getAllWindowHandles();
var mainhandle = await driver.getWindowHandle();
windowhandles.forEach(async newwindow => {
console.log(newwindow);
if(newwindow != mainhandle){
await driver.switchTo().window(newwindow);
console.log("switching to window " + newwindow)
var exists = await driver.findElements(By.css('#App > div > div.MuiPaper-root.MuiCard-root.jss10.MuiPaper-elevation1.MuiPaper-rounded > div.MuiCardHeader-root.jss14 > div.MuiCardHeader-action > button')).then(found => !!found.length);
if(exists==true){
console.log("ayyyyyyy we made it") ;
const newtask = await driver.findElement(By.css('#App > div > div.MuiPaper-root.MuiCard-root.jss10.MuiPaper-elevation1.MuiPaper-rounded > div.MuiCardHeader-root.jss14 > div.MuiCardHeader-action > button'));
newtask.click();
exists=false
}
else{
var testhandle = await driver.getWindowHandle();
console.log("Element not found in " + testhandle);
}
// await driver.close();
}
else{
console.log("this must be the main "+ mainhandle)
}
})
Edit: I thought I should add that each "switching to window" test output shows a new window but the "element not found" always shows the last window handle. I'm not sure if this is just an issue with how I am testing and viewing my output or if there is something more to it.