Clicking on a link in a table - webdriver

I have a table of four columns. The data in the first column is a name of a group in which I can click on to go to a new page to modify the group data.
I can get the text of that group name, but I am unable to click on it. I'm trying to go through each row and get the status of each group (located in column 4). If it's on hold, I want to modify the data of that group.
Here is my code: Why will it not click on the group name?
List<WebElement> elems = driver.findElements(By.xpath("//table[#id='nameOfTable']/tbody/tr"));
for (WebElement rowElem : elems)
{
List<WebElement> cells = rowElem.findElements(By.xpath("td"));
if(cells.get(3).getText().equalsIgnoreCase("Hold"))
{
System.out.println(cells.get(0).getText()); //
cells.get(0).click; // This will not click on the link
}
}

It is because you are clicking the whole cell, not the link inside the cell. Try:
cells.get(0).findElements(By.TagName("a")).Click();
If the link is an <a> tag it will work, but you can use id, classname, etc... if it isn't.

You would need to say cells.get(0).click();.
I believe you are missing a couple of parentheses...

Related

Select one cell and by clicking a button change value of a different cell

I want to insert a button into my google spreadsheet, that, when clicked, copies the content of the selected cell to another cell. Is there any way to do this?
I tried googling for a solution myself, but I'm overwhelmed by all sorts of different scripts/macros/addons that are available.
Would be amazing if you could help me out on this one.
you will need a script for this purpose like:
function moveValuesOnly1() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var selection = SpreadsheetApp.getActiveSpreadsheet().getSelection();
var currentCell = selection.getCurrentCell();
source.copyTo(ss.getRange("Sheet2!B1"), {contentsOnly: true}); }
which copies selected cell from selected sheet into B1 cell of Sheet2
and then just go Insert > Drawings and create a button. when done link the script with button and you are done.

Is it possible to load AppMaker DropDowns with an Option Text and and Value?

I've been able to set the options on an AppMaker DropDown by doing this sort of thing:
google.script.run
.withSuccessHandler(function(oA){app.pages.Notes.descendants.Dropdown1.options=oA;})
.getSelectOptions();//oA is just an array
But I'd like to know how to do load different values in the options and value like we can do it in javascript with something like this:
function updateSelect(vA){
var select = document.getElementById("sel1");
select.options.length = 0;
for(var i=0;i<vA.length;i++)
{
select.options[i] = new Option(vA[i].option,vA[i].value);
}
}
And I tried this by trying to get a hold of the dom element as follows:
var elem=app.pages.myPage.descendants.myDropDown.getElement();
elem.options.length=0;//always gives me an error because options doesn't seem to exist in that object.
So for now I've been using the standard HTML dom elements in an AppMaker Html widget and that works okay as long as your select is on the first page. If it's not on the first page I have found that the onChange event can't load Widgets on pages that are not visible. It is interesting to note however that you can change the contents of HTML widgets even if they are on other non visible pages.
Anyway the simple question is how can one load one thing into value and another thing into option text in an AppMaker DropDown Widget?
<option value="value">text</option>
If you have a predefined array for your options and values you could do the following for your onAttach Event of your dropdown:
var options = ['one thing','two thing','three thing'];
var names = ['another one thing','another two thing','another three thing'];
widget.options = options;
widget.names = names;
In this case the values that would get recorded would be the options array, but the items that would be displayed would be from the names array. Hope this gets you on the right path.

Disabling a row in a DOJO / Gridx grid

I have a grid I created in Gridx which lists a bunch of users. Upon clicking a ROW in the grid (any part of that row), a dialog pops up and shows additional information about that user and actions that can be done for that user (disable user, ignore user, etc.) - when one of these options is selected from the pop up, I want to DISABLE that row. The logic for getting the row, etc. I can take care of, but I can't figure out how to make a grid row actually "appear" disabled and how to make that row no longer clickable.
Is there a simple way to do this? If you aren't familiar with gridx, solutions that apply to EnhancedGrids or other Dojo grids are also appreciated.
Alright now that I have a little more information here is a solution:
Keep a list of all the rows you have disabled so far either inside the Grid widget or in its parent code. Then on the onRowClick listener I would write code like this:
on(grid, "onRowClick", function(e) {
if(disabledRows[rowIndex]) {
return;
}
// Do whatever pop up stuff you want and after
// a user selects the value, you can "disable"
// your row afterwards by adding it to the disabled
// list so that it can no longer be clicked on.
var rowIndex = e.rowIndex;
disabledRows[rowIndex] = true;
// This is just some random class I made up but
// you can use css to stylize the row however you want
var rowNode = e.rowNode;
domClass.add(rowNode, "disabled");
});
Note that domClass is what I named "dojo/dom-class". Hope this helps!
This is perhaps not exactly what you are seaching for:
If you want to hide one or more rows by your own filterfunction you could just add to these rows in the DOM your own class for nodisplay. Here I show you a function for display only those rows which have in a choiceable field/column a value inside your filterlist.
function hideRowFilter(gridId, fieldName, filterList)
{
var store = gridId.store;
var rowId;
store.query(function(object){
rowId = gridId.row(object.id,true).node();
if (filterList.indexOf(object[fieldName]) == -1)
domClass.add(rowId, "noDisplay"); // anzeigen
else
domClass.remove(rowId, "noDisplay"); // verstecken
});
}
CSS:
.noDisplay { display: none; }
So I can for example display only the entries with a myState of 3 or 4 with this call:
hideRowFilter(gridId, 'myState', [3, 4]);
Note that domClass is what I named "dojo/dom-class"

Extjs4 how to disable itemClick event of grid's certain column

I am working in extjs4. I have grid panel view as=
i want to show image in floating window whenever user clicks on grid row.So i have written function namely showImage() and calling it as=
me.mon(me, {'itemclick' : me.showImageViewer
}, me);
But i dont want to call this function when user clicks on FileName column of grid. So how to restrict calling showImage function when user clicks on grid column 'FileName'
You can listen to the column click function. Define common listener for columns you need. In arguments you should recieve grid, cell element, row index, column index, event data and record(in such order). So if you'll move, rename headers or do whatever you want with column with such listener it wouldn't change click listener.
i want to show image in floating window whenever user clicks on grid row.
Do you mean you'll show a popup containing the bigger image if image on row is clicked? if yes, on your showImageViewer function, you have to check the attributes of the cell if it's an image or you can check its dataIndex.
You can also listen to cellClick instead of itemClick. With that, you can check the cellIndex of the cell being clicked. In your case, if cellIndex is equal to 2 (index of your FileName column, don't call showImageViewer.
cellClick : function(view, cell, cellIndex, record, row, rowIndex, e) {
}
You can use a css selector to differentiate between elements inside the row, using a code like the following
listeners: {
itemclick: {
fn: function (view, record, item, index, e, eOpts) {
var photo = e.getTarget('.photo');
if(photo) {
alert(record.get('photo'));
}
}
}
You can try a working sample here. Hope it helps to solve your problem

How to find out the selected row of an html table

I have made a html table in asp.net. The user clicks on a row and the corresponding page for that record is opened. How do i know which row of the table has the user selected?
http://www.electrictoolbox.com/jquey-make-entire-table-row-clickable/
$(document).ready(function() {
$('#example tr').click(function() {
alert('clicked');
});
});
How to tell which row number is clicked in a table?
without jquery
Adding an onclick event to a table row
http://jsbin.com/ivobe
try to set custom attribute of id to row(html) by assinging database id value to it.
by clicking on that row , you can get access that custom attribute by $(this).attr('your_custom_attr') and you can use that value to make ajax GET call.

Resources