Skip to content

Wait.until(ExpectedConditions.invisibilityOfElementLocated()) always fails for negative scenarios #7510

@KiranTest

Description

@KiranTest

💬 Questions and Help

In my application I'm using .until(ExpectedConditions.invisibilityOfElementLocated()) for verifying Home page details.

Steps to reproduce:

  1. Launch Firefox and navigate to http://newtours.demoaut.com/
  2. Enter Valid user Name and Invalid pass word and click on Login
  3. verify the title

Actual issue: My script fails with exception in the step 2 itself. Below are the script and log details. Its been observed that it is working fine for the positive scenario, valid user name and valid password.

How can we wait till the next page loads so that I can get title and compare.

	driver = new FirefoxDriver();
	driver.manage().window().maximize();
	//driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
	driver.get("http://newtours.demoaut.com/");
	driver.findElement(By.name("userName")).sendKeys("valid password");
	driver.findElement(By.name("password")).sendKeys("invalid password");
	driver.findElement(By.name("login")).click();
	WebDriverWait wait = new WebDriverWait(driver, 60);
	wait.until(ExpectedConditions.invisibilityOfElementLocated(By.name("login")));
	titleActual = driver.getTitle();
	if (titleActual.equals(titleExpected)) {
		System.out.println("Login successful");
	} 
	else {

Logs:
Aug 21, 2019 5:38:37 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to no longer be visible: By.name: login (tried for 60 second(s) with 500 milliseconds interval)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'LAPTOP-2PL6I9SD', ip: '192.168.43.30', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.1'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 67.0.3, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20190618025334, moz:geckodriverVersion: 0.24.0, moz:headless: false, moz:processID: 15188, moz:profile: C:\Users\SWATHI\AppData\Loc..., moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, platformVersion: 10.0, rotatable: false, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: e2401e63-ffda-45cd-a73f-ea418e38236d
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:95)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:272)
at basic_tests.LoginFlightTest.main(LoginFlightTest.java:33)

Please note that this issue tracker is not a help form and this issue will be closed.

For questions or help please see:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions