Could someone please assist me in following issue: i have to pickup from dropdown elements which have - Open as a part of title (as per on screenshot below)
Since that value will be change during time period, it is useless to use that, and have to pickup ones with 'Open' status (not showed, but rest of statuses are: Frozen & Closed) So, here is xpath which I tried:
//*[@id="period"]/contains(@text, '')
For above i got result from test is true. (It does exist text as I understand that) But when add wanted text
//*[@id="period"]/contains(@text, 'Open')
I got as a result false and can not find elements. Also, when searched with:
//*[@id="period"]
I got result (all periods are shown).
01. Oct 2018 - 31. Oct 2018 - Open01. Sep 2018 - 30. Sep 2018 - Open01. Aug 2018 and so on ...
HTML is as follows:
<main class="main row">
<div class="content clearfix column medium-8">
<div class="row">
<article class="column medium-12">
<div class="t-box">
<p></p><div class="compete">
<a class="button primary" href="« Back to overview</a>
<div class="promotion">
<h2 class="promotion-header"><img src="/assets/images/system/stats/language/EN.png.pagespeed.ce.nTcGwJ7dzC.png">Top of the month</h2>
<form class="row" method="GET" action="/compete">
<input type="hidden" name="id" value="3">
<div class="column large-2">
<label for="period"><strong> <br>Period:</strong></label>
</div>
<div class="column large-8">
<select id="period" name="period">
<option value="39">01. Oct 2018 - 31. Oct 2018 - Open</option><option value="38">01. Sep 2018 - 30. Sep 2018 - Open</option><option value="37">01. Aug 2018 - 31. Aug 2018 - Open</option><option value="36">01. Jul 2018 - 31. Jul 2018 - Open</option><option value="35">01. Jun 2018 - 30. Jun 2018 - Open</option><option value="34">01. May 2018 - 31. May 2018 - Open</option><option value="33">01.
What I am doing wrong, please assist.
To print all the months which have Open
as a part of title you can use the following code block :
Select months = new Select(driver.findElement(By.id("period")));
List<WebElement> monthList = months.getOptions();
for(WebElement month:monthList)
if(month.getAttribute("innerHTML").contains("Open"))
System.out.println(month.getAttribute("innerHTML"));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments