I had some hard time using HOT table in Angular unit tests (asked different question). No advance with my task I decided to do e2e testing (protractor->selenium under the hood). Now I have 2 issues
- I dont know how to paste tabular data using copy-paste
- I don’t know how to insert text into selected cell
as for 1. I have tried to simulate paste event like this
function simulatePaste(data: string, pasteTarget: WebdriverWebElement) {
const script = `
var event=new Event('paste',{});
console.log('arguments inner',arguments);
event.clipboardData={getData:function(){return \`${data}\`}}
console.log('potential data',event.clipboardData.getData());
arguments[0].dispatchEvent(event);
`;
return browser.executeScript(script, pasteTarget);
}
where pasteTarget
is selected table cell. Its not working obviousyly. How to paste data using selenium driver?
- I have tried to iterate over set of cells and
sendKeys
to it but it fails withFailed: element not interactable
.
const cell = this.cell(row, col);
await cell.click();
await cell.sendKeys(data[row][col]);
where cell
is and ElementFinder
pointing to td eg hot-table div.ht_master table tbody tr:nth-child(3) td:nth-child(3)
How to set cell value using selenium driver?