Files
BordroRobot/app/lib/bot/rodhelper.go
2024-03-30 15:35:53 +03:00

26 lines
720 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package bot
import (
"time"
"github.com/go-rod/rod"
)
type Select struct {
Element *rod.Element
Selector string
}
func (elemSelector *Select) SelectItem(changeValue string) error {
_, err := elemSelector.Element.Evaluate(rod.Eval(`document.querySelector("` + elemSelector.Selector + `").value = "` + changeValue + `";`))
_, err = elemSelector.Element.Evaluate(rod.Eval(`document.querySelector("` + elemSelector.Selector + `").dispatchEvent(new Event('change'));`))
return err
}
func WaitLoad(frm *rod.Page) error { // belli bir süre redirect ten önceki js fonksiyonunun tamamlanması bekleniyor
wait := frm.WaitRequestIdle(50*time.Millisecond, nil, nil, nil)
wait()
err := frm.WaitLoad()
return err
}