I use agouti package in golang. I run selenium docker image, and create a new web driver with the following command:
capabilities := agouti.NewCapabilities().Browser("chrome").With("javascriptEnabled")
command := []string{"java", "-jar", "selenium-server.jar", "-port", "4444"}
driver = agouti.NewWebDriver("http://127.0.0.1:4444/wd/hub", command, agouti.Desired(capabilities))
I create a new page and try to set a value of an element in this page. I find element with xpath by using the following command:
var selection = page.FindByXPath(xpath)
Then try to send key with SendKeys() method of Agouti, but it does not set the value to the element. I tried to send an API call to the selenium by using the JSON Wire Protocol of the selenium. In this case, I need the id of the element to send the request. I try to obtain the id of the element with the following code:
elems, _ := selection.Elements()
id := elems[0].ID
But when I print the id, I saw that it is empty. So my request is not sent. The error I get is like following:
request unsuccessful: Unable to execute request for an existing session: POST /session/bba01dd19db3a063304a40b59b4cefb7/element//value
The main reason is of the error is that the id of the element is empty.
Btw, when I use chrome driver it works properly
args = append(args, "disable-blink-features=AutomationControlled")
chromeOpts := agouti.ChromeOptions("args", args)
options = append(options, chromeOpts)
driver = agouti.ChromeDriver(options...)
I dont understand why i can not use the selenium in agouti, and why the id of the element is empty. I hope that I explain my problem. Thanks