Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.openqa.selenium.NoSuchElementException after using navigate() #331

Open
qqilihq opened this issue Aug 19, 2018 · 0 comments
Open

org.openqa.selenium.NoSuchElementException after using navigate() #331

qqilihq opened this issue Aug 19, 2018 · 0 comments

Comments

@qqilihq
Copy link
Contributor

qqilihq commented Aug 19, 2018

After using the com.machinepublishers.jbrowserdriver.JBrowserDriver.navigate() API (e.g. for reloading or navigating back), I receive a org.openqa.selenium.NoSuchElementException when trying to work with the WebDriver (e.g. on getPageSource() or findElementsBy…).

Seems that the driver still tries to access the previously loaded page. I did a quick digging through the source code, but couldn't find anything related on first sight. In case somebody can give me a hint where to look, I'd be willing to provide a fix.

Here's a minimal test case which shows the issue:

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.machinepublishers.jbrowserdriver.JBrowserDriver;

public class NavigationIssues {

	private JBrowserDriver driver;

	@Before
	public void before() {
		driver = new JBrowserDriver();
	}

	@After
	public void after() {
		driver.quit();
		driver = null;
	}

	@Test
	public void test_navigateRefresh() {
		driver.get("http://example.com");
		driver.navigate().refresh();
		assertNotNull(driver.getPageSource());
		assertEquals(1, driver.findElementsByXPath("//h1").size());
	}

	@Test
	public void test_navigateBack() {
		driver.get("http://example.com");
		driver.get("http://example.edu");
		driver.navigate().back();
		assertNotNull(driver.getPageSource());
		assertEquals(1, driver.findElementsByXPath("//h1").size());
	}

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant