Skip to content

Commit d23700e

Browse files
committed
Added example test where expected condition expected "locator" tuple
Some of the expected conditions expect a locator which is a tuple consisting of the By string [1] and the string containing the locator. I wanted to see what this was like. I am thinking that it would be good to somehow use the libraries locator strategy. Needed to also add to the test page so we had a new element after a delay. [1] https://www.selenium.dev/selenium/docs/api/py/_modules/selenium/webdriver/common/by.html#By
1 parent b022031 commit d23700e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

atest/acceptance/keywords/expected_conditions.robot

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ Wait For Non Existing Expected Conditions
4444
Run Keyword And Expect Error this_is_not_an_expected_con_dition is an unknown expected condition
4545
... Wait For Expected Condition this_is not an expected con dition ${dynamic_btn}
4646
47-
47+
Wait For Expected Conditions When Condition Includes Locator
48+
Title Should Be Original
49+
${byElem}= Evaluate ("id","added_btn")
50+
Click Element link:delayed add element
51+
Wait For Expected Condition Presence Of Element Located ${byElem}
52+
Click Element id:added_btn

atest/resources/html/javascript/expected_conditions.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
55
<title>Original</title>
6+
<!-- Note the timeouts in the functions are chosen such they constitute
7+
a set with distinct subset sums. That is is a combination of any two
8+
or more were to be executed the total time for that distinct combination
9+
would be unique. This was done so we could do a ALL/AND/OR type of test
10+
and know that with the combination of expected conditions the execution
11+
was successful as the unique time took place. -->
12+
<!-- The set we are using is {6,9,11,12,13} -->
13+
<!-- (could also use {3,5,6,7} which would reduce total time)-->
614
<script type="text/javascript">
715
function add_content(target_container, content) {
816
p = document.createElement('p');
@@ -28,11 +36,23 @@
2836
document.title='Delayed';
2937
},600);
3038
}
39+
40+
function delayed_add_element() {
41+
setTimeout(function(){
42+
const newElem = document.createElement("input");
43+
newElem.setAttribute("type", "button");
44+
newElem.setAttribute("id", "added_btn");
45+
newElem.setAttribute("value", "Added Button");
46+
const container = document.getElementById("container");
47+
document.body.insertBefore(newElem, container);
48+
},1100);
49+
}
3150
</script>
3251
</head>
3352
<body>
3453
<a href="javascript:return false;" onclick="document.title='Changed'; return false;">change title</a><br/>
3554
<a href="javascript:return false;" onclick="delayed_title_change(); return false;">delayed change title</a><br/>
55+
<a href="javascript:return false;" onclick="delayed_add_element(); return fales;">delayed add element</a><br/>
3656
<a href="javascript:return false;" onclick="add_content('target', 'added content'); return false;">add content</a><br/>
3757
<a id="unicode" href="javascript:return false;" onclick="document.title='äää'; return false;">title to ääää</a><br/>
3858
<p>
@@ -56,6 +76,9 @@
5676
<input type=button id=enabledDisabledBtn value="Disabled"
5777
disabled />
5878
</p>
79+
<p>
80+
<div id="container"></div>
81+
</p>
5982
<p>
6083
<form name=titleChanger>
6184
<td>

0 commit comments

Comments
 (0)