-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
How to wait till page reloads/redirects after clicking button #184
Comments
Can you provide minimal code for us to reproduce your issue? |
If a page is like this, I want to click the button, how can we define what is page loaded? <html>
<body>
</body>
<script>
setTimeout(() => {
document.body.innerHTML = '<button>click</button>'
}, 1000 * randomSeconds)
</script>
</html> In this case, the race selectors is the only choice for me. |
Here is the entire code. page := Browser.Page("https://codeforces.com/enter").WaitLoad()
page.Element("#handleOrEmail").Input(usr)
page.Element("#password").Input(passwd)
page.Element(".submit").Click()
time.Sleep(time.Millisecond*300)
page.WaitLoad()
// Check if in the home page now
page.Screenshot("") |
Don't forget to log our conversation in discord 😃 |
Thanks for the answer @ysmood. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
You have 2 options:
Option 1 is what you'd aim to do, if the web page doesn't reload on submit. Plus it's faster, if you know exactly what you're searching for. Option 2 is suitable for all other cases. |
Also, the API changed a lot since when this issue was filed, you are looking for the method |
This comment has been minimized.
This comment has been minimized.
@zplzpl If you are not comfortable using English please use https://www.deepl.com/ to translate your mother tongue. Your words don't make sense to me 😂 Please raise another issue for your question, yours is not related to the current one. Also, please read this #322. |
Thanks for the suggestion, I'll reopen an issue. |
if page redirect by js with settimeout u can do this for {
// if u find a nonexistent elment by Elment directly will hang up even with out for{}
// so u must use Has before Element
if page.MustHas("#error_display") {
fmt.Println("loginErr")
break
}
info := page.MustInfo()
if strings.HasPrefix(info.URL, "other domain") {
fmt.Println("loginSuccess")
break
}
time.Sleep(time.Second)
} |
Currently, I do something like this:
Is there any better way than this? One way I tried (but failed was)
The text was updated successfully, but these errors were encountered: