Skip to content

Commit 44e64d1

Browse files
authored
Merge pull request #51 from autifyhq/hiroki/fix-description-assert-checked
Add "Press Enter" and "Get a value of input or textarea element" snippets.
2 parents 22bdec0 + 8677ea6 commit 44e64d1

File tree

10 files changed

+167
-15
lines changed

10 files changed

+167
-15
lines changed

content/en/snippets/assertions/assert_checked.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ weight: 10
44
ie_support: true
55
---
66

7-
Use this snippet to assert that a checkable element (such as a radio button implemented as `<input type="radio">`) is checked or not, in case it is not possible with Recorder.
7+
Use this snippet to assert whether a checkable element is checked or not, in case it is not possible with currently supported assertions.
88

9-
Refer to the following document for currently supported assertions by Recorder.
10-
11-
https://help.autify.com/docs/list-of-assertions
9+
Please check <a href="https://help.autify.com/docs/list-of-assertions" target="_blank">**here**</a> for currently supported assertions.
1210

1311
Change the following values to fit your test case:
1412

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "Keyboard"
3+
weight: 30
4+
---
5+
6+
{{< toc-tree >}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Press Enter"
3+
weight: 10
4+
ie_support: false
5+
---
6+
7+
Use this snippet to fire a pressing Enter key event on an element.
8+
9+
Change the following value to specify the element:
10+
11+
- `selector`: A string of the element selector
12+
13+
```js
14+
/*
15+
* Specify the element selector
16+
*/
17+
var selector = "<TODO: REPLACE SELECTOR>";
18+
var element = document.querySelector(selector);
19+
20+
/*
21+
* Exit if it does not exist
22+
*/
23+
if (!element) {
24+
throw new Error(
25+
"Error: cannot find the element with selector(" + selector + ")."
26+
);
27+
}
28+
29+
/* Create and init a pressing Enter key event */
30+
var enterEvent = new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true });
31+
32+
/* Fire a pressing Enter key event */
33+
element.dispatchEvent(enterEvent);
34+
```

content/en/snippets/scroll/scroll_to_element.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
---
2-
title: "Scroll until an element is visible"
2+
title: "Scroll until an element is displayd"
33
weight: 20
44
ie_support: false
55
---
66

7-
Scroll to a specified element in the entire page.
7+
Scroll down the page until the specific element is displayed.
8+
9+
Change the following value to specify the element:
10+
11+
- `selector`: A string of the element selector
812

913
```js
1014
/**
@@ -23,7 +27,8 @@ if (!element) {
2327
}
2428

2529
/**
26-
* Scroll to the bottom of the element
30+
* Scroll until the element is displayed.
31+
* If the block value is set to "center", the element will scroll to the center of the page.
2732
*/
28-
element.scrollIntoView(false);
33+
element.scrollIntoView({block: "end", inline: "nearest", behavior: "smooth"});
2934
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Get the value entered into an Input or Textarea element"
3+
weight: 60
4+
ie_support: true
5+
---
6+
7+
Use this snippet to return the value entered into a `<input>` element or a `<textarea>` element.
8+
9+
Change the values written below.
10+
11+
- `selector`: A string of a selector to pinpoint the element.
12+
13+
```js
14+
/**
15+
* Locate the element
16+
*/
17+
var selector = "<TODO: REPLACE SELECTOR>";
18+
var element = document.querySelector(selector);
19+
20+
/**
21+
* Stop process if it does not exist
22+
*/
23+
if (!element) {
24+
throw new Error(
25+
"Error: cannot find the element with selector(" + selector + ")."
26+
);
27+
}
28+
29+
/**
30+
* Return the value entered for the element
31+
*/
32+
return element.value;
33+
```

content/ja/snippets/assertions/assert_checked.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ weight: 10
44
ie_support: true
55
---
66

7-
レコーダーで検証できないチェック可能要素 (`<input type="radio">` で実装されたラジオボタンなど) がチェックされているかどうかのアサーションを行いたい場合にご利用ください
7+
「チェックボックスが選択されている/いないことを確認する」アサーションで、検証できないチェック可能要素をアサーションしたい場合にご利用ください
88

9-
現在レコーダーでサポートされているアサーションについては、以下をご確認ください。
10-
11-
https://help.autify.com/docs/ja/list-of-assertions
9+
現在サポートされているアサーションについては<a href="https://help.autify.com/docs/ja/list-of-assertions" target="_blank">**こちら**</a>をご確認ください。
1210

1311
以下の値をテストケースに合うように変更してください:
1412

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "キーボード操作"
3+
weight: 30
4+
---
5+
6+
{{< toc-tree >}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Enterキーを押下する"
3+
weight: 10
4+
ie_support: false
5+
---
6+
7+
CSSセレクターを指定して見つかった要素に対して、Enterキーを押下するイベントを発生させるのに使用します。
8+
9+
以下の値を変更してください。
10+
11+
- `selector`: 対象要素を特定するCSSセレクターの文字列
12+
13+
```js
14+
/**
15+
* 要素を探す
16+
*/
17+
var selector = "<TODO: REPLACE SELECTOR>";
18+
var element = document.querySelector(selector);
19+
20+
/**
21+
* 要素がなければ処理を中断する
22+
*/
23+
if (!element) {
24+
throw new Error(
25+
"Error: cannot find the element with selector(" + selector + ")."
26+
);
27+
}
28+
29+
/* Enterキーの押下のイベントを生成し初期化する */
30+
var enterEvent = new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true });
31+
32+
/* Enterキーの押下のイベントを発生させる */
33+
element.dispatchEvent(enterEvent);
34+
```

content/ja/snippets/scroll/scroll_to_element.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ weight: 20
44
ie_support: false
55
---
66

7-
特定の要素の位置までページをスクロールします。
7+
特定の要素が表示されるまでページをスクロールします。
8+
9+
以下の値を対象要素に合わせて変更してください。
10+
11+
- `selector`: 要素を特定するCSSセレクターの文字列
812

913
```js
1014
/**
@@ -23,7 +27,8 @@ if (!element) {
2327
}
2428

2529
/**
26-
* 要素の下が表示されるまでスクロールする
30+
* 要素が表示されるまでスクロールする
31+
* 要素を真ん中までスクロールする場合はblockの値を"center"に変更してください
2732
*/
28-
element.scrollIntoView(false);
33+
element.scrollIntoView({block: "end", inline: "nearest", behavior: "smooth"});
2934
```
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Input要素やTextarea要素に入力された値を取得する"
3+
weight: 60
4+
ie_support: true
5+
---
6+
7+
`<input>`要素や`<textarea>`要素に入力された値を取得したい時にご利用ください。
8+
9+
以下の値を変更してください。
10+
11+
- `selector`: 対象要素を特定するCSSセレクターの文字列
12+
13+
```js
14+
/**
15+
* 要素を探す
16+
*/
17+
var selector = "<TODO: REPLACE SELECTOR>";
18+
var element = document.querySelector(selector);
19+
20+
/**
21+
* 要素がなければ処理を中断する
22+
*/
23+
if (!element) {
24+
throw new Error(
25+
"Error: cannot find the element with selector(" + selector + ")."
26+
);
27+
}
28+
29+
/**
30+
* 要素に入力された値を返す
31+
*/
32+
return element.value;
33+
```

0 commit comments

Comments
 (0)