Giter Club home page Giter Club logo

Comments (5)

licanhua avatar licanhua commented on July 19, 2024

有没有可能需要perform? 列如 await actions.click(element).perform()

你能提供WinAppDriver的log吗

from selenium-appium.

s0521 avatar s0521 commented on July 19, 2024

1.当使用driver.actions().contextClick(Projec_item1)命令不加.perform()时:
1.1对应的测试脚本:

beforeAll(() => {
return TestEnvironment.setup();;
})

afterAll(() => {
return TestEnvironment.teardown();
})

describe('Calculator Test', () => {
test('Plus', async () => {
let Projec_item1 = await By2.nativeName("aa");
await driver.actions().contextClick(Projec_item1);
expect(await Projec_item1.getText()).toBe('dddd');
})
});

1.2对应的WinAppDriver显出出的日志:
C:\Program Files (x86)\Windows Application Driver>WinAppDriver.exe
Windows Application Driver listening for requests at: http://127.0.0.1:4723/
Press ENTER to exit.

==========================================
POST /session HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 197
Content-Type: application/json;charset=UTF-8
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

{"desiredCapabilities":{"browserName":"","platformName":"windows","deviceName":"WindowsPC","appTopLevelWindow":"0xE08DC"},"capabilities":{"alwaysMatch":{"browserName":"","platformName":"windows"}}}
HTTP/1.1 200 OK
Content-Length: 128
Content-Type: application/json

{"sessionId":"07E746E6-372E-46F3-B488-3AF731570FC0","status":0,"value":{"appTopLevelWindow":"0xE08DC","platformName":"windows"}}

==========================================

POST /session/07E746E6-372E-46F3-B488-3AF731570FC0/elements HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 29
Content-Type: application/json;charset=UTF-8
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

{"using":"name","value":"aa"}
HTTP/1.1 200 OK
Content-Length: 115
Content-Type: application/json

==========================================
GET /session/07E746E6-372E-46F3-B488-3AF731570FC0/element/42.197826.4.-1123595248.663/text HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 0
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

HTTP/1.1 200 OK
Content-Length: 76
Content-Type: application/json

{"sessionId":"07E746E6-372E-46F3-B488-3AF731570FC0","status":0,"value":"aa"}

==========================================
DELETE /session/07E746E6-372E-46F3-B488-3AF731570FC0 HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 0
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

HTTP/1.1 200 OK
Content-Length: 12
Content-Type: application/json

{"status":0}

==========================================
DELETE /session/6328E0E6-22A3-4DE3-BB14-B7174ADC9895 HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 0
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

HTTP/1.1 200 OK
Content-Length: 12
Content-Type: application/json

1.3对应的yarn run jest命令返回的信息:
C:\Users\Administrator\Desktop\tc2>yarn run jest
yarn run v1.22.17
$ jest --maxWorkers=1
FAIL tests/calculator.spec.ts
Calculator Test
× Plus (2749 ms)

● Calculator Test › Plus

expect(received).toBe(expected) // Object.is equality

Expected: "dddd"
Received: "aa"

  36 |         let Projec_item1 = await By2.nativeName("aa");
  37 |         await driver.actions().contextClick(Projec_item1);
> 38 |         expect(await Projec_item1.getText()).toBe('dddd');
     |                                              ^
  39 |
  40 |     })
  41 | });

  at Object.<anonymous> (__tests__/calculator.spec.ts:38:46)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5.713 s, estimated 6 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

2.当使用driver.actions().contextClick(Projec_item1)命令并且,添加.perform()时:
2.1对应的测试脚本:

beforeAll(() => {
return TestEnvironment.setup();;
})

afterAll(() => {
return TestEnvironment.teardown();
})

describe('Calculator Test', () => {
test('Plus', async () => {
let Projec_item1 = await By2.nativeName("aa");
await driver.actions().contextClick(Projec_item1).perform();
expect(await Projec_item1.getText()).toBe('dddd');
})
});

2.2对应的WinAppDriver显出出的日志:

C:\Program Files (x86)\Windows Application Driver>WinAppDriver.exe
Windows Application Driver listening for requests at: http://127.0.0.1:4723/
Press ENTER to exit.

==========================================
POST /session HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 197
Content-Type: application/json;charset=UTF-8
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

{"desiredCapabilities":{"browserName":"","platformName":"windows","deviceName":"WindowsPC","appTopLevelWindow":"0xE08DC"},"capabilities":{"alwaysMatch":{"browserName":"","platformName":"windows"}}}
HTTP/1.1 200 OK
Content-Length: 128
Content-Type: application/json

{"sessionId":"A3B8AFBD-4117-4CB9-9B70-29B40E22C804","status":0,"value":{"appTopLevelWindow":"0xE08DC","platformName":"windows"}}

==========================================
POST /session/A3B8AFBD-4117-4CB9-9B70-29B40E22C804/actions HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 257
Content-Type: application/json;charset=UTF-8
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

{"actions":[{"actions":[{"type":"pointerMove","origin":{"using":"name","value":"aa"},"duration":100,"x":0,"y":0},{"type":"pointerDown","button":2},{"type":"pointerUp","button":2}],"parameters":{"pointerType":"mouse"},"type":"pointer","id":"default mouse"}]}
HTTP/1.1 500 Internal Error
Content-Length: 138
Content-Type: application/json

{"status":104,"value":{"error":"unsupported operation","message":"Currently only pen and touch pointer input source types are supported"}}

==========================================
DELETE /session/A3B8AFBD-4117-4CB9-9B70-29B40E22C804 HTTP/1.1
Accept: application/json; charset=utf-8
Connection: close
Content-Length: 0
Host: localhost:4723
User-Agent: selenium/4.1.1 (js windows)

HTTP/1.1 200 OK
Content-Length: 12
Content-Type: application/json

{"status":0}

2.3对应的yarn run jest命令返回的信息:
C:\Users\Administrator\Desktop\tc2>yarn run jest
yarn run v1.22.17
$ jest --maxWorkers=1
FAIL tests/calculator.spec.ts
Calculator Test
× Plus (71 ms)

● Calculator Test › Plus

WebDriverError: Currently only pen and touch pointer input source types are supported

  35 |
  36 |         let Projec_item1 = await By2.nativeName("aa");
> 37 |         await driver.actions().contextClick(Projec_item1).perform();
     |         ^
  38 |         expect(await Projec_item1.getText()).toBe('dddd');
  39 |
  40 |     })

  at Object.checkLegacyResponse (node_modules/selenium-webdriver/lib/error.js:558:15)
  at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:540:13)
  at Executor.execute (node_modules/selenium-webdriver/lib/http.js:474:28)
  at WebDriver.execute (node_modules/selenium-webdriver/lib/webdriver.js:735:17)
  at Actions.perform (node_modules/selenium-webdriver/lib/input.js:878:5)
  at Object.<anonymous> (__tests__/calculator.spec.ts:37:9)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 3 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

3.小结
添加.proform()会导致“WebDriver”发生报错,提示:当前只有“笔”和“触摸”输入源支持.perform()

from selenium-appium.

licanhua avatar licanhua commented on July 19, 2024

看来需要perform
你可以执行https://github.com/microsoft/WinAppDriver/blob/master/Tests/WebDriverAPI/Mouse.cs,代码的第77行。 看她发出来的消息长什么样。
https://github.com/microsoft/WinAppDriver/blob/master/Docs/SupportedAPIs.md 看, actions是不支持的。
你可以在产品中加一个按钮,点击的时候触发右键菜单

from selenium-appium.

s0521 avatar s0521 commented on July 19, 2024

我似乎水平太菜了,我不会你所说的这些操作。。。。。。。
我不知道该如何直接执行“WinAppDriver”中的命令
,也不会在产品中“增加一个按钮”,,我无法修改我测试的“对象(产品)”

你可以给出一个简单的“使用Javascript直接向WinAppDriver发送请求”的演示么?
感谢~!

from selenium-appium.

licanhua avatar licanhua commented on July 19, 2024

可能最接近的是WebDriver.execute。他的代码在

https://github.com/SeleniumHQ/selenium/blob/b3f9d377d04dcefb5bfbc6fbdaffccf946bfedda/javascript/node/selenium-webdriver/lib/webdriver.js#L253

execute<T>(command: Command, description?: string | undefined): Promise<T> {

可能
···
const webdriver = abc
...
webdriver.execute(command)
···

from selenium-appium.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.