Im in a situation that the window that asks me to choose a wizard to proceed with my project is not appearing on a Button Click. It clicks the button successfully but i dont see the window. Referred to multiple blogs that didnt help me to resolve this issue.
Below is the HTML snippet of that window
<div data-reactroot="" class="backdrop custom-modal-dialog"><div class="wizard-selection-modal-dialog-box"><div class="header-container"><h1 class="flex-grow">Wizard Window</h1><div class="icon icon-close close"></div></div><div class="warning-box"><div class="icon icon-info-circle"></div><div class="info-text">Please choose the assess type you want to proceed</div></div><div class="selection-container"><div class="selection-box selected"><h1>Standard Assess</h1><div class="facts-container"><div class="fact-block"><div class="icon icon-check"></div><div class="fact-text">Instruction1</div></div><div class="fact-block"><div class="icon icon-check"></div><div class="fact-text">Instruction2</div></div><div class="fact-block"><div class="icon icon-check"></div><div class="fact-text">Instruction3</div></div></div><div class="selection-indicator"><div class="icon icon-check"></div></div></div><div class="selection-box"><h1>Group Assess</h1><div class="facts-container"><div class="fact-block"><div class="icon icon-check"></div><div class="fact-text">Instruction1</div></div><div class="fact-block"><div class="icon icon-check"></div><div class="fact-text">Instruction2</div></div><div class="fact-block"><div class="icon icon-check"></div><div class="fact-text">Instruction3</div></div></div><div class="selection-indicator"></div></div></div><div class="footer-container"><div class="continue-container"><div class="continue-text">Continue Assess</div><div class="icon icon-sent-offers"></div></div></div></div>
Below is the HTML script of the button that I click to open the wizard window,
<div class="offer-item" id="offer-item-0069E000005uD7PQAU"><div class="opportunity-item"><div class="offer-column"><div class="offer-name no-contracts"><!-- react-text: 135 -->Optimum Wartung256<!-- /react-text --><div class="offline-offer icon icon-offline hidden"><div class="last-sync-started"></div></div></div><div class="opportunity-filters"><div class="opportunity-filter">Omförhandling</div></div></div><div class="building-column"><div class="building-equipment-info"><div class="buildings"><span class="icon icon-building"></span><span class="count">0</span></div></div></div><div class="opportunity-status-column"><div class="opportunity-close-date">26.9.2017</div><div class="opportunity-status">Starta bedömningen</div></div></div></div>
Below is the code that I used,
public void BeginAssessWizardWindow(String opportunityStr) {
try {
List<WebElement> opportunities = driver.findElements(By.xpath("//a[@class='offer-item']"));
for (WebElement opportunite : opportunities) {
WebElement OpportunityName = opportunite.findElement(By.cssSelector("div.offer-name.no-contracts"));
String textval = OpportunityName.getText();
if (textval.equalsIgnoreCase(opportunityStr)) {
//WebElement BeginAssessButton =opportunite.findElement(By.cssSelector("div.opportunity-status"));
//WebDriverWait wait = new WebDriverWait(driver, 100);
//wait.until(ExpectedConditions.visibilityOfElementLocated (By.cssSelector ("div.opportunity-status")));
//WaitAndClickElementDirectly(BeginAssessButton);
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementByClass('opportunity-status').click();");
//Thread.sleep(1000);
//checkPageIsReady();
//FluentWaitClick(BeginAssessButton);
logger.info("Entered into Begin Assess function" + textval);
break;
}
}
//Thread.sleep(1000);
CheckAssessmentWizardWindow();
}
catch(Exception e)
{
Assert.fail("Couldn't proceed with Assessments" + e);
//CheckAssessmentWizardWindow();
}
}
public void CheckAssessmentWizardWindow()
{
try {
//checkPageIsReady();
WebElement WizardWindow = FindTheElement("cssSelector",AssessmentPageData.AssessmentWizard);
WaitTillClickable("cssSelector",AssessmentPageData.AssessmentWizard);
if(WizardWindow.isDisplayed())
{
//WaitTillElementVisible("xpath",AssessmentPageData.AssessmentWizard);
WaitAndClickOnElement("xpath",AssessmentPageData.AssessmentOption);
WaitTillElementVisible("xpath",AssessmentPageData.AssessmentPage);
ClickOnElement("xpath",AssessmentPageData.AssessmentPage);
}
else
{
}
}
catch(Exception e)
{
Assert.fail(e);
}
}
Please suggest me some possible ways how to resolve such situation.
Code to check whether the page is ready,
public void checkPageIsReady() {
JavascriptExecutor js = (JavascriptExecutor)driver;
//Initially bellow given if condition will check ready state of page.
if (js.executeScript("return document.readyState").toString().equals("complete")){
System.out.println("Page Is loaded.");
return;
}
//This loop will rotate for 25 times to check If page Is ready after every 1 second.
//You can replace your value with 25 If you wants to Increase or decrease wait time.
for (int i=0; i<25; i++){
try {
Thread.sleep(1000);
}catch (InterruptedException e) {}
//To check page ready state.
if (js.executeScript("return document.readyState").toString().equals("complete")){
break;
}
}
}