You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`seleniumgenic` has zero dependencies. It mearly takes in a given Selenium [WebDriver](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebDriver.html) instance and works with it's API. Since the suites of core Selenium packages are constantly updating and only work with the latest versions of browsers, it will be the aim to keep `seleniumgenic` always working with the latest versions of the [selenium-webdriver](https://www.selenium.dev/selenium/docs/api/javascript/index.html).
144
+
145
+
## Component Objects
146
+
147
+
Component Objects represent individual or groups of elements on a page. Like with the example above, components could be the individual INPUT elements, or represent a Login form that might be reused on multiple pages in an application.
148
+
149
+
### Import
150
+
151
+
```javascript
152
+
const { Component } =require('seleniumgenic');
153
+
```
154
+
155
+
### Constructor
156
+
157
+
Creates a Component instance. Takes a single `props` object as a parameter. Either a Selenium By or Selenium WebElement must be provided.
158
+
159
+
TIP: While Components can be created via the Constructor, it is highly recommended to make use of the `createComponent(s)` functions of Page and Component classes as they will take care of creating the Component instance with proper `driver` and `scope` properties as well as determining if the By or WebElement should be utilized.
160
+
161
+
**Props**
162
+
-`driver`: The current Selenium WebDriver instance. Required.
163
+
-`by`: The Selenium By that is used to locate the Component. If not provided, `webElement` must be provided.
164
+
-`scope`: The scope in which to use the By to locate the Component. Must be a WebDriver or Component. Optional, will default to the `driver` if not provided.
165
+
-`webElement`: The Selenium WebElement object that represents the Component. If not provided, `by` must be provided.
166
+
167
+
### clear() => Promise<undefined>
168
+
169
+
Clears the value if this Component represents an INPUT or TEXTAREA element.
170
+
171
+
### click() => Promise<undefined>
172
+
173
+
Clicks this Component.
174
+
175
+
### contextClick() => Promise<undefined>
176
+
177
+
Performs a contenxt/right click on this Component.
178
+
179
+
### createComponent(props) => Component
180
+
181
+
Convenience method for instantiating a Component within the scope of this Component.
182
+
183
+
**props**
184
+
185
+
-`by`: The Selenium By that is used to locate the Component. Required.
186
+
-`componentClass`: The class/type of Component that the Component should be created as. Optional, will default to `Component` class.
Gets an object that describes this Component's location and size.
218
+
219
+
### getTagName() => Promise<String>
220
+
221
+
Gets the Components HTML tag name.
222
+
223
+
### getText(raw = false) => Promise<String>
224
+
225
+
Gets the text contained within this Component. The default is to get the text as it is visually displayed to the user. The 'raw' flag can be used to ge the text as it is provided to the HTML of the page.
226
+
227
+
-`raw`: Boolean, flag that indicates if the text shoudl be retrieved in its raw form.
228
+
229
+
### hoverClick() => Promise<undefined>
230
+
231
+
Performs the actions of hovering the mouse over the Component and then left-clicking it. Great for Components that are not displayed or able to be interacted with unless the Component is hovered over first.
232
+
233
+
### isDisplayed() => Promise<Boolean>
234
+
235
+
Gets a value indicating if the Component is currently displayed.
236
+
237
+
### isEnabled() => Promise<Boolean>
238
+
239
+
Gets a value indicating if the Component is currently enabled.
240
+
241
+
### isPresent() => Promise<Boolean>
242
+
243
+
Gets a value indicating if the Component is present (exists).
244
+
245
+
### isSelected() => Promise<Boolean>
246
+
247
+
Gets a value indicating if the Component is currently selected.
248
+
249
+
### sendKeys(...args) => Promise<undefined>
250
+
251
+
Types a key sequence on the DOM element that this Component represents. See [WebElement.sendKeys()](https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_WebElement.html#sendKeys) for more details.
252
+
253
+
### submit() => Promise<undefined>
254
+
255
+
Submits the form that this Component is part of, or the form itself if this Component represents a FORM element.
256
+
257
+
### takeScreenshot() => Promise<String>
258
+
259
+
Takes a screenshot of visible area of this Component and returns the base-64 encoded PNG.
260
+
261
+
-`scroll`: Indicates if the Component should be scrolled into view to take the screenshot. Optional.
0 commit comments