Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. WebDriver
  2. =========
  3. > A lightweight, non-opinionated implementation of the [WebDriver specification](https://w3c.github.io/webdriver/webdriver-spec.html) including mobile commands supported by [Appium](http://appium.io/)
  4. There are [tons](https://github.com/christian-bromann/awesome-selenium#javascript) of Selenium and WebDriver binding implementations in the Node.js world. Every one of them have an opinionated API and recommended way to use. This binding is the most non-opinionated you will find as it just represents the [WebDriver specification](https://w3c.github.io/webdriver/webdriver-spec.html) and doesn't come with any extra or higher level abstraction. It is lightweight and comes with support for the [WebDriver specification](https://w3c.github.io/webdriver/webdriver-spec.html) and Appium's [Mobile JSONWire Protocol](https://github.com/appium/appium-base-driver/blob/master/docs/mjsonwp/protocol-methods.md).
  5. ## Install
  6. To install this package from NPM run:
  7. ```sh
  8. $ npm i webdriver
  9. ```
  10. ## Example
  11. The following example demonstrates a simple Google Search scenario:
  12. ```js
  13. import WebDriver from 'webdriver';
  14. (async () => {
  15. const client = await WebDriver.newSession({
  16. path: '/',
  17. capabilities: { browserName: 'firefox' }
  18. })
  19. await client.navigateTo('https://www.google.com/ncr')
  20. const searchInput = await client.findElement('css selector', '#lst-ib')
  21. await client.elementSendKeys(searchInput['element-6066-11e4-a52e-4f735466cecf'], 'WebDriver')
  22. const searchBtn = await client.findElement('css selector', 'input[value="Google Search"]')
  23. await client.elementClick(searchBtn['element-6066-11e4-a52e-4f735466cecf'])
  24. console.log(await client.getTitle()) // outputs "WebDriver - Google Search"
  25. await client.deleteSession()
  26. })()
  27. ```
  28. # Configuration
  29. To create a WebDriver session call the `newSession` method on the `WebDriver` class and pass in your configurations:
  30. ```js
  31. import WebDriver from 'webdriver'
  32. const client = await WebDriver.newSession(options)
  33. ```
  34. The following options are available:
  35. ### capabilities
  36. Defines the [capabilities](https://w3c.github.io/webdriver/webdriver-spec.html#capabilities) you want to run in your Selenium session.
  37. Type: `Object`<br>
  38. Required: `true`
  39. ### logLevel
  40. Level of logging verbosity.
  41. Type: `String`<br>
  42. Default: *info*<br>
  43. Options: *trace* | *debug* | *info* | *warn* | *error* | *silent*
  44. ### protocol
  45. Protocol to use when communicating with the Selenium standalone server (or driver).
  46. Type: `String`<br>
  47. Default: *http*
  48. Options: *http* | *https*
  49. ### hostname
  50. Host of your WebDriver server.
  51. Type: `String`<br>
  52. Default: *localhost*
  53. ### port
  54. Port your WebDriver server is on.
  55. Type: `Number`<br>
  56. Default: *4444*
  57. ### path
  58. Path to WebDriver endpoint or grid server.
  59. Type: `String`<br>
  60. Default: */*
  61. ### queryParams
  62. Query parameters that are propagated to the driver server.
  63. Type: `Object`
  64. Default: `null`
  65. ### connectionRetryTimeout
  66. Timeout for any WebDriver request to a driver or grid.
  67. Type: `Number`<br>
  68. Default: *120000*
  69. ### connectionRetryCount
  70. Count of request retries to the Selenium server.
  71. Type: `Number`<br>
  72. Default: *2*
  73. ### agent
  74. Allows you to use a custom` http`/`https`/`http2` [agent](https://www.npmjs.com/package/got#agent) to make requests.
  75. Type: `Object`<br>
  76. Default:
  77. ```js
  78. {
  79. http: new http.Agent({ keepAlive: true }),
  80. https: new https.Agent({ keepAlive: true })
  81. }
  82. ```
  83. ### transformRequest
  84. Function intercepting [HTTP request options](https://github.com/sindresorhus/got#options) before a WebDriver request is made
  85. Type: `(RequestOptions) => RequestOptions`<br>
  86. Default: *none*
  87. ### transformResponse
  88. Function intercepting HTTP response objects after a WebDriver response has arrived
  89. Type: `(Response, RequestOptions) => Response`<br>
  90. Default: *none*