Selenium driver for testing SpreadJS

你说的曾经没有我的故事 提交于 2019-12-11 15:22:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!