Selecting value from oi-select dropdown in selenium - selenium

In my application there is oi-select dropdown which contains dynamic value. I want to select value from dropdown. I tried below code but it always select 1st element in the list
for(WebElement skill:selectSkill) {
System.out.println(".............................."+skill.getText());
if(skill.getText().equals(expectedSkills)) {
skill.sendKeys(Keys.ENTER);
break;
}
}

Instead of skill.sendKeys(Keys.ENTER); , use below code-
Select select = new Select(driver.findElement(By.xpath("xpath of the dropdown here")));
select.selectByVisibleText(expectedSkills);

Related

DataTables Select filter with fixed column

So, I have a DataTable with left fixed column but wanted to add a Select like filter, which is not supported by datatables.
I created the select filter and it works just fine withouth the fixed column as it filters from the original table. The thing is when I fix the left column, it doesn't apply the filter into the cloned table
I've tried adding and 'id' into the cloned table and then applying the filter into it too, but it won't work
As it is seen in the picture, the filter 'Externas' it's applied and should only show the orange rows, but the fixed columns shows every row
Fixed column not filtering
This is my select
<select id="filtrarTipo" onclick="filtradoTipo(); filtradoTipoC();">
<option value="" selected disabled>Seleccione</option>
<option value="">Todas</option>
<option value="Interna">Interna</option>
<option value="Externa">Externa</option>
</select>
And my jquery
function filtradoTipo() {
// Declare variables
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("filtrarTipo");
filter = input.value.toUpperCase();
table = document.getElementById("dtBecas");
tr = table.getElementsByTagName("tr");
// Loop through all table rows, and hide those who don't match the search query
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[4];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}

How to select first 5 webelements and iterate?

List nines=driver.findElements(By.xpath(("//select[contains(#id,'ddlIN_HH')]")));
for(WebElement nine : nines)
{ Select s= new Select(nine);
s.selectByValue("09");
}
you can select first 5 elements directly using xpath function position()
so your new xpath would be
List nines=driver.findElements(By.xpath(("//select[contains(#id,'ddlIN_HH')]")[position() < 6]));

Retrieve data from Array to text-boxes on select change

I want to auto-populate data in text-boxes for in VUE. I have this set of array.
[
{"ID":"1","Name":"JOHN DOE","Email":"JohnDoe#GMAIL.COM","Phone Number":"58656","Address":"Somewhere"},
{"ID":"2","Name":"JANE ZOE","Email":"JohnDoe#GMAIL.COM","Phone Number":"9969","Address":"Anywhere"},
{"ID":"3","Name":"JENNY JAMES DOE","Email":"JJames#GMAIL.COM","Phone Number":"888888","Address":"Everywhere"}
]
CODE PEN https://codepen.io/hiro-john/pen/jOOwwza?editors=1010`
If anyone select, 'JOHN DOE' from the Dropdown Name , his details should be auto-populate to the respective fields which are 'Email, Phone & Address' from the Array List. User can add more than 1 Person and each Person data should populate base on 'Name' Dropdown.
Used this function to search inside the Array.
function indexWhere(array, conditionFn) {
const item = array.find(conditionFn)
return array.indexOf(item)
}
And bind the value on Select Change Event.
const index = indexWhere(items, item => item.Name === name)
this.shareholders[id].Address = items[index].Address;
this.shareholders[id].Email = items[index].Email;
this.shareholders[id].Phone = items[index].Phone;
Updated CODE PEN https://codepen.io/hiro-john/pen/jOOwwza?editors=1010

using listdata only and get from another model in Yii

can i just have listdata by itself? The list doesn't list anything, all I keep getting is "Array" as the return.
I have:
$awards= $model->findAll('uid='.$uid);
return CHtml::listData($awards, 'award_id', '$data->award->name');
try this code:
$awards= $model->findAll(array('condition'=>'uid ='.$uid)); // get records from table
return CHtml::listData($awards, 'award_id', 'award_name'); // third parameter should the array value. Most of the case we use to display in combo box option text.
If you are getting from another table, then declare a variable in your award model.
public $awrd_name;
Then you have to get records using relation in criteria.
Output will be :
array("1" => "award1", "2" => "award2", "3" => "award3");
refer this link : http://www.yiiframework.com/forum/index.php/topic/29837-show-two-table-fields-in-dropdownlist/

select a record from a list-box using text in Protractor

I want to select the record from the list box using text. how can i use the filter function to select the particular record. I will be having many options but i want to select the value which i want by checking the text (e.g Spanish). I dont want to select value by index becoz if i do that i wont be able to verify test, moreover list gets updated. kindly help. below r my html code.
<ul class="addList">
<li ng-repeat="skill in availableSkills" ng-click="addSkillFunc(skill, $index)" class="ng-binding ng-scope">Mandarin</li>
<li ng-repeat="skill in availableSkills" ng-click="addSkillFunc(skill, $index)" class="ng-binding ng-scope">English</li>
<li ng-repeat="skill in availableSkills" ng-click="addSkillFunc(skill, $index)" class="ng-binding ng-scope">Spanish</li>
</ul>
Yea i can select the record by index. but i want something like selectbyvisibleText which is available in Selenium.
Finally got the solution. created a function SelectRowByCellValue and used to call it where ever i want by
SelectRowByCellValue(AGP.SkillList, Data.SkillSelect);
SkillList = element.all(by.css('Ul.addList li'));
SkillSelect = Value that u want to select. (Spanish)
this.SelectRowByCellValue = function (Elem, Texts) {
Elem.filter(function (element) {
return element.getText().then(function (text) {
if (text == Texts) {
element.click();
return false;
}
});
}).then(function (filteredElements) {
});
};