问题
How could I make click(events) on the basis of cell position in spreadJs? I try something like:
sheet.setActiveCell(3,3);
sheet.cellClick();
and
sheet.getCell(3,3).cellClick();
But it's not working. Thanks in advance if any solution or advice.
回答1:
What you would need to do is essentially create an instance of an action using selenium. For example, you could have a web driver open Chrome, and navigate to one of our samples like so:
var webDriver = new OpenQA.Selenium.Chrome.ChromeDriver();
webDriver.Navigate().GoToUrl("https://www.grapecity.com/en/demos/spread/JS/ExcelMobileSample/");
Then calculate the x/y coordinates for the current page by using getCellRect and the offset of the SpreadJS host element:
var cellRect = sheet.getCellRect(3, 3);
var host = spread.getHost();
var offset = $(host).offset();
cellRect.x += offset.left + cellRect.width / 2;
cellRect.y += offset.top + cellRect.height / 2;
Then you would move the mouse to the center position of a cell (in this case, cell D4):
var action = new OpenQA.Selenium.Interactions.Actions(webDriver);
action.MoveByOffset(x, y);
And then finally click on that cell:
action.Click();
action.Perform();
Let me know if that helps.
Regards,
Spread Team
来源:https://stackoverflow.com/questions/51700072/selenium-driver-for-testing-spreadjs