Using selenium web driver, me need to get the set of option values such as Last 30 days, Last 60 days etc.
I have tried to get those elements using CSS selector.
var timeperiodcss = "div.k-animation-container div.k-list-container.k-popup.k-group.k-reset div ul#selectDefaultTimePeriod li.k-item";
var elements = element.FindElements(By.CssSelector(timeperiodcss));
if (elements.Count >= 1)
break;
Every time elements.count is showing as 0. Not able to get those elements.
The following is the HTML content for those cases
<div class="k-animation-container" style="width: 150px; height: 206px; margin-left: -10px; padding-left: 10px; padding-right: 10px; padding-bottom: 15px; box-sizing: content-box; overflow: hidden; display: none; position: absolute; top: 1039.55px; z-index: 10002; left: 87.45px;">
<div id="selectDefaultTimePeriod-list" class="k-list-container k-popup k-group k-reset" data-role="popup" style="position: absolute; height: 200px; display: none; font-size: 13px; font-family: "Roboto",sans-serif; font-stretch: normal; font-style: normal; font-weight: 400; line-height: 18px; width: 144px; transform: translateY(204px);">
<div class="k-list-optionlabel">Select time period</div>
<div class="k-group-header" style="display:none"></div>
<div unselectable="on" style="overflow: auto; position: relative; height: 175px;">
<ul id="selectDefaultTimePeriod_listbox" class="k-list k-reset" unselectable="on" tabindex="-1" aria-hidden="true" aria-live="off" data-role="staticlist" role="listbox">
<li class="k-item" data-offset-index="0" unselectable="on" role="option" tabindex="-1">Last 30 days</li>
<li class="k-item" data-offset-index="1" unselectable="on" role="option" tabindex="-1">Last 60 days</li>
<li id="0936dfb5-4f8c-4dd4-826f-f802b6a719ff" class="k-item k-state-selected k-state-focused" data-offset-index="2" unselectable="on" role="option" tabindex="-1">Last 90 days</li>
<li class="k-item" data-offset-index="3" unselectable="on" role="option" tabindex="-1">Last month</li>
<li class="k-item" data-offset-index="4" unselectable="on" role="option" tabindex="-1">Last quarter</li>
<li class="k-item" data-offset-index="5" unselectable="on" role="option" tabindex="-1">Last 6 months</li>
<li class="k-item" data-offset-index="6" unselectable="on" role="option" tabindex="-1">Last 12 months</li>
<li class="k-item" data-offset-index="7" unselectable="on" role="option" tabindex="-1">Last 365 days</li>
<li class="k-item" data-offset-index="8" unselectable="on" role="option" tabindex="-1">Full year 2016</li>
</ul>
</div>
</div>
Please let me know, Is it have any other option to get those elements.
You can select those element by using xpath in two steps.
Step 1: click on the drop down. //you need to do this, as after clicking on the drop down only the html for drop down list will become visible.
code: driver.findElement(By.id("selectDefaultTimePeriod_listbox")).click();
Step 2: Select the li element by using xpath.
Code: drive3r.findElement(By.xpath("//ul/li[text()='Last 30 days']"));
Related
i have a span tag which is conditionally rendered using v-if in vuejs. if user is null then it should
not be rendered and if user is not null then only it should be rendered. now when a user logged in, it
is being displayed, upto here its working, but when user click on logout, then it should not rendered but still its rendering
My code snippet is below
<span class="user-options" id="user-opt" v-if="user">
<ul class="user-details">
<li style="background: #000000; color: white; text-align: center; line-height: 30px;">
Welcome {{ user.username }}
</li>
<li style="text-align: center; background: white; color: black; line-height: 30px;">
email {{ user.username }}
</li>
<li style="background: white; color: black; line-height: 30px;" v-if="user.verified">
verified
<span style="float: right; color: blue;">
<i class="fas fa-check-circle"></i>
</span>
</li>
<li style="line-height: 30px;" v-if="user.verified">
total post
<span style="float: right">
{{ user.totalPost }}
</span>
</li>
<li style="text-align: center; line-height: 30px;" v-on:click="logOut">
logout
</li>
</ul>
</span>
when user click logout still its showing untill i refresh the page its rendering some content of span tag
problem was v-if="user"
<span class="user-options" id="user-opt" v-if="user ">
instead of above i used this code and everything is resolved
<span class="user-options" id="user-opt" v-if="user != null">
I tried to enter the value(search Engine) and select the option in combo box. Unable to enter and select option in combo box.
Tried with to click first using
js=(JavascriptExecutor)driver;
js.executeScript("$(\"#divProfileSetting li:nth-child(2) span\").click()");
Here is the HTML source,
<div class="controls" id="divSearchEngine">
<div class="k-widget k-multiselect k-header span12" unselectable="on" style="">
<div class="k-multiselect-wrap k-floatwrap" unselectable="on">
<ul role="listbox" unselectable="on" class="k-reset" id="searchEngine_taglist"></ul>
<input class="k-input k-readonly" style="width: 157px;" accesskey="" role="listbox" aria-expanded="false" tabindex="0" aria-owns="searchEngine_taglist searchEngine_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false">
<span class="k-icon k-loading k-loading-hidden"></span>
</div>
<select class="span12" id="searchEngine" multiple="multiple" name="searchEngine" data-role="multiselect" aria-disabled="false" aria-readonly="false" style="display: none;">
<option value="1:AF">Google Afghanistan</option>
<option value="1:AX">Google Ă…land</option>
<option value="1:AL">Google Albania</option>
</select>
<span style="font-family: CenturyRegular; font-size: 12px; font-stretch: 100%; font-style: normal; font-weight: 400; letter-spacing: normal; text-transform: none; line-height: 15.72px; position: absolute; visibility: hidden; top: -3333px; left: -3333px;">Select Search Engine...</span>
</div>
</div>
js=(JavascriptExecutor)driver;
js.executeScript("$('#searchEngine-list ul li:eq(1)').click()");
js=null;
This code worked
I need to know how we can select a value from drop down combo box using value of that item.
Below is the form tag
<form id="rahul" onkeypress="EnterHandler();" onsubmit="javascript:return WebForm_OnSubmit();" action="./RequestSubmission?CC8510F49CCCF2&" method="post">
<div class="rcbSlide" style="z-index: 6000; visibility: visible; display: block; overflow: visible; margin-left: 0px; position: absolute; top: 575.2px; left: 768.183px; height: 202px; width: 300px;">
<div id="ctl00_MainContent_ucAdditionalDetailsMAP_txtResponsiblePerson_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_MetroTouch rcbAutoWidth rcbAutoWidthResizer" style="display: block; visibility: visible; top: 0px; left: 0px; transition: none 0s ease 0s ;">
<div class="rcbScroll rcbWidth rcbNoWrap" style="height: 200px; width: 100%; overflow: auto;">
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">
<li class="rcbItem">Aava, Ruth</li>
<li class="rcbItem">Abdelgawwad, Khaled</li>
<li class="rcbItem">Achcar, Cecilia</li>
<li class="rcbItem">Achilles, Karin</li>
<li class="rcbItem">Adachi, Masatoshi</li>
<li class="rcbItem">admin, bayer</li>
<li class="rcbItem">Adriane, Fernandes</li>
<li class="rcbItem">Aeschliman, Lisa</li>
<li class="rcbItem">Afonja, Olubunmi</li>
</ul>
</div>
</div>
</div>
</form>
Here is the div tag from where we are selecting the value from drop down combo box.
<div id="ctl00_MainContent_ucAdditionalDetailsMAP_txtResponsiblePerson" class="RadComboBox RadComboBox_MetroTouch" style="width:350px;">
<table class="" style="border-width: 0px; border-collapse: collapse;" summary="combobox">
<tbody>
<tr>
<td class="rcbInputCell rcbInputCellLeft" style="width:100%;">
<input id="ctl00_MainContent_ucAdditionalDetailsMAP_txtResponsiblePerson_Input" class="rcbInput radPreventDecorate rcbEmptyMessage" type="text" value="Select" name="ctl00$MainContent$ucAdditionalDetailsMAP$txtResponsiblePerson" autocomplete="off">
</td>
<td class="rcbArrowCell rcbArrowCellRight">
<a id="ctl00_MainContent_ucAdditionalDetailsMAP_txtResponsiblePerson_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;">select</a>
</td>
</tr>
</tbody>
</table>
</div>
I want to know how we can select li item "Aava, Ruth" in selenium webdriver using its value.
Use below XPath
//ul[#class='rcbList']/li[1]
OR
//ul[#class='rcbList']/li[contains(.,'Aava, Ruth')]
You can select it directly by using below code:-
driver.findElement(By.xpath("//ul[#class='rcbList']/li[1]")).click();
Note:- First click on dropbox then use above code
Hope it will help you :)
<div id="from-list" class="k-list-container k-popup k-group k-reset k-state-border-up" data-role="popup" style="height: auto; display: block; font-size: 16px; font-family: "TR",arial; font-stretch: normal; font-style: normal; font-weight: 500; line-height: 23.2px; width: 206.6px; transform: translateY(0px); position: absolute;">
<ul id="from_listbox" class="k-list k-reset" unselectable="on" style="overflow: auto; height: auto;" tabindex="-1" role="listbox" aria-hidden="false" aria-live="polite">
<li class="k-item" unselectable="on" data-idx="0" role="option" tabindex="-1">pr.sud#en.com</li>
<li class="k-item" unselectable="on" data-idx="1" role="option" tabindex="-1">pra.melu#en.com</li>
<li class="k-item" unselectable="on" data-idx="2" role="option" tabindex="-1">prast.bha#en.com</li>
<li class="k-item" unselectable="on" data-idx="3" role="option" tabindex="-1">prp#savant.com</li>
</ul>
</div>
I try to automate above code its not working
I used this code
dr.findElement(By.id("from-list")).findElement(By.id("from_listbox")).click();
List<WebElement> liList = dr.findElements(By.id("from_listbox"));
liList.get(0).click();
liList.get(1).click();
Please let me know if any of have idea about that
int liSize = driver.findElements(By.xpath(".//*[#id='from_listbox']/li")).size();
for(int j = 1; j <= liSize; j++) {
String liLocator = String.format(".//*[#id='from_listbox']/li[%d]", j);
driver.findElement(By.xpath(liLocator)).click();
}
Problem is at the end of the XPATH before i didn't add (/li)
After i saw ur mesage i add that (/li). Its working fine.
List listItems = dr.findElements(By.xpath(".//*#id='from_listbox']/li"));
listItems2.get(0).click();
How can I add 2 more rows to the JSSOR tiled menu slider? Thank you.
Given a slide defined as follows, you will see all content in a slide is fully customizable. To define 4 rows instead of 2 rows, you can edit css.
<div>
<a class=appicon01 style="left: 0px; top: 0px; background-position:0px 0px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 01</div>
</a>
<a class=appicon01 style="left: 160px; top: 0px; background-position:-160px 0px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 02</div>
</a>
<a class=appicon01 style="left: 320px; top: 0px; background-position:-320px 0px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 03</div>
</a>
<a class=appicon01 style="left: 480px; top: 0px; background-position:-480px 0px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 04</div>
</a>
<a class=appicon01 style="left: 640px; top: 0px; background-position:-640px 0px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 05</div>
</a>
<a class=appicon01 style="left: 0px; top: 160px; background-position:0px -160px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 06</div>
</a>
<a class=appicon01 style="left: 160px; top: 160px; background-position:-160px -160px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 07</div>
</a>
<a class=appicon01 style="left: 320px; top: 160px; background-position:-320px -160px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 08</div>
</a>
<a class=appicon01 style="left: 480px; top: 160px; background-position:-480px -160px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 09</div>
</a>
<a class=appicon01 style="left: 640px; top: 160px; background-position:-640px -160px;" href="#">
<div class=appiconcb></div>
<div class=appiconc>Menu Item 10</div>
</a>
</div>