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

The element reference of...is stale #312

Open
BrunoMCBraga opened this issue Mar 15, 2023 · 1 comment
Open

The element reference of...is stale #312

BrunoMCBraga opened this issue Mar 15, 2023 · 1 comment

Comments

@BrunoMCBraga
Copy link

BrunoMCBraga commented Mar 15, 2023

Hello

I am currently using selenium to automate a login and I am using the following sequence:

userNameElement, err = wd.FindElement(selenium.ByName, "user_name")
	if err := wd.Get(loginURL); err != nil {
		return errors.New(fmt.Sprintf("... failed on wd.FindElement #username with error: %s", err.Error()))
	}

	if err := userNameElement.Clear(); err != nil {
		return errors.New(fmt.Sprintf("...failed on elem.Clear with error: %s", err.Error()))
	}

I keep getting the same error and the browser crashes. The error is on the description.

I have found this stale error on stackoverflow posts and with the Pythin version of selenium it is possible to ignore this type of error or at least use a Wait to wait until the form is loaded.

There is no way for me to block this exceptions according to the source code and I have no idea how to handle this error. I have tried sleep and wait but the error keeps triggering again.

Thanks

@draganm
Copy link

draganm commented Jun 30, 2023

Think you should swap the order of Get() and FindElement() - Get will instruct the browser to load the page, so whatever element reference you got before Get() is guaranteed to be invalid.

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

2 participants