使用protogen工具后,我有一个发送消息的消息类型:
Using the selenium server at http://0.0.0.0:4723/wd/hub
[launcher] Running 1 instances of WebDriver
Started
F
Failures:
1) my app should make the login test
Message:
Failed: browser.driver.findelement is not a function
Stack:
TypeError: browser.driver.findelement is not a function
at Object.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:26:17)
at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:96:23
at new Promise (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1043:7)
at controlFlowExecute (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:82:18)
at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2697:25
at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: Run it("should make the login test") in control flow
at Object.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:81:14)
From asynchronous test:
Error
at Suite.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:15:1)
at Object.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:13:1)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
1 spec, 1 failure
Finished in 0.03 seconds
[launcher] 0 instance(s) of WebDriver still running
[launcher] safari #01 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code 1
我正在尝试使用type File struct {
Info string `protobuf:"bytes,1,opt,name=info,json=info" json:"info,omitempty"`
BytesValues []byte `protobuf:"bytes,2,opt,name=bytes_values,json=bytesValues,proto3" json:"bytes_values,omitempty"`
}
字段发送一些二进制数据,如下所示:
BytesValues
服务器似乎在解码我发送给它的消息时遇到问题。这是使用带有协议缓冲区的filePath := filepath.Join("test", "myfile.bin")
f, _ := ioutil.ReadFile(filePath) // error return value ignored for brevity
msg := File{BytesValues: f}
body, _ := proto.Marshal(msg) // encode
字段发送二进制数据的正确方法吗?
答案 0 :(得分:0)
就我而言,问题实际上是服务器没有从正确的字段中读取原始字节。
发送原始字节的正确方法是将字节设置为字段。不需要以任何方式对字节进行编码,因为协议缓冲区是二进制格式。
filePath := filepath.Join("test", "myfile.bin")
f, _ := ioutil.ReadFile(filePath) // error return value ignored for brevity
msg := File{BytesValues: f}
body, _ := proto.Marshal(msg) // encode