Skip to content

Commit

Permalink
Added example test where expected condition expected "locator" tuple
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emanlove committed Jan 21, 2024
1 parent b022031 commit d23700e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion atest/acceptance/keywords/expected_conditions.robot
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ Wait For Non Existing Expected Conditions
Run Keyword And Expect Error this_is_not_an_expected_con_dition is an unknown expected condition
... Wait For Expected Condition this_is not an expected con dition ${dynamic_btn}
Wait For Expected Conditions When Condition Includes Locator
Title Should Be Original
${byElem}= Evaluate ("id","added_btn")
Click Element link:delayed add element
Wait For Expected Condition Presence Of Element Located ${byElem}
Click Element id:added_btn
23 changes: 23 additions & 0 deletions atest/resources/html/javascript/expected_conditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Original</title>
<!-- Note the timeouts in the functions are chosen such they constitute
a set with distinct subset sums. That is is a combination of any two
or more were to be executed the total time for that distinct combination
would be unique. This was done so we could do a ALL/AND/OR type of test
and know that with the combination of expected conditions the execution
was successful as the unique time took place. -->
<!-- The set we are using is {6,9,11,12,13} -->
<!-- (could also use {3,5,6,7} which would reduce total time)-->
<script type="text/javascript">
function add_content(target_container, content) {
p = document.createElement('p');
Expand All @@ -28,11 +36,23 @@
document.title='Delayed';
},600);
}

function delayed_add_element() {
setTimeout(function(){
const newElem = document.createElement("input");
newElem.setAttribute("type", "button");
newElem.setAttribute("id", "added_btn");
newElem.setAttribute("value", "Added Button");
const container = document.getElementById("container");
document.body.insertBefore(newElem, container);
},1100);
}
</script>
</head>
<body>
<a href="javascript:return false;" onclick="document.title='Changed'; return false;">change title</a><br/>
<a href="javascript:return false;" onclick="delayed_title_change(); return false;">delayed change title</a><br/>
<a href="javascript:return false;" onclick="delayed_add_element(); return fales;">delayed add element</a><br/>
<a href="javascript:return false;" onclick="add_content('target', 'added content'); return false;">add content</a><br/>
<a id="unicode" href="javascript:return false;" onclick="document.title='äää'; return false;">title to ääää</a><br/>
<p>
Expand All @@ -56,6 +76,9 @@
<input type=button id=enabledDisabledBtn value="Disabled"
disabled />
</p>
<p>
<div id="container"></div>
</p>
<p>
<form name=titleChanger>
<td>
Expand Down

0 comments on commit d23700e

Please sign in to comment.