I am a beginner in selenium, I am using java for thatU nill yesterday this code was working well, it showed me same exception for the button named "show". I searched for it and solved it. But again today its showing for clicking on list please help me. Also can I use wait named as domPropertyToBe
My java code:
import java.time.Duration;
import java.util.List;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
public class erp {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Tools\\Selenium\\Chromedriver96\\chromedriver_win32 (1)\\chromedriver.exe");
WebDriver dChromedriver=new ChromeDriver();
dChromedriver.get("https://erp.mitwpu.edu.in/");
dChromedriver.manage().window().maximize();
WebElement txtPassword=dChromedriver.findElement(By.id("txtPassword")) ;
WebElement txtUserId=dChromedriver.findElement(By.id("txtUserId")) ;
txtUserId.sendKeys("S1032200787");
txtPassword.sendKeys("FynS@3XbZH6ZMWH");
//
WebDriverWait w =new WebDriverWait(dChromedriver, Duration.ofSeconds(30));
w.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='ReCaptchContainer']")));
dChromedriver.findElement(By.xpath("//div[@id='ReCaptchContainer']")).click();
// Thread.sleep(3000);
w.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("label#lblMessage")));
WebElement success_lablElement=dChromedriver.findElement(By.cssSelector("label#lblMessage"));
Assert.assertEquals(success_lablElement.getText(),"Success" );
dChromedriver.findElement(By.id("btnLogin")).click();
WebElement resultWebElement=dChromedriver.findElement(By.xpath("//nav[@class=\"mt-2\"]/ul/li[12]/a[@href=\"Examination/Report/StudentGradeCardDetail.aspx?MENU_CODE=Web_Result\"]"));
resultWebElement.click();
w.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("FrameContent")));
// w.until(ExpectedConditions.elementToBeClickable(By.id("drpSem_Arrow")));
dChromedriver.findElement(By.id("drpSem_Arrow")).click();
w.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.tagName("li")));
List<WebElement> listElement=dChromedriver.findElements(By.tagName("li"));
w.until(ExpectedConditions.elementToBeClickable(By.id("btnshow")));
WebElement show_buttonElement=dChromedriver.findElement(By.id("btnshow"));
// dChromedriver.findElement(By.cssSelector("a[onclick=\"$find('ReportViewer1').exportReport('PDF');\"]"));
for (WebElement list : listElement) {
if (list.getText().equals("SY BTech - CSE / TRIMESTER-V / 2020-21 / Middle")) {
list.click(); // This is the line I get error
show_buttonElement.click();
}
}
}
// public static void myfunction() {
// try {
// Robot robot = new Robot();
// Thread mthread = new Thread(mlauncher);
// mthread.start();
//
// robot.keyPress(KeyEvent.VK_ENTER);
// robot.keyRelease(KeyEvent.VK_ENTER);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}