我使用C#中的Selenium Webdriver在UI上测试网格,网格上有网格。
网格有自己的滚动条,我想向下滚动到网格的底部,以检查当我通过模态窗体添加它时出现的某个结果(UI测试当前失败,因为它无法看到结果直到我向下滚动)。
如何定位网格上的滚动条而不是主网页上的普通滚动条? 这是我的网格滚动条的HTML:
<div class="ScrollbarLayout_face ScrollbarLayout_faceVertical public_Scrollbar_face" style="height: 367.38px; transform: translate3d(0px, 148.535px, 0px); backface-visibility: hidden;"></div>我正在考虑使用下面的代码,但我想不出如何将网格底部的元素定位到滚动到?
WebElement element = driver.findElement(By.id("my-id")); Actions actions = new Actions(driver); actions.moveToElement(element); actions.perform();I am UI-testing a web page with a grid on it, using Selenium Webdriver in C#.
The grid has its own scroll bar and I would like to scroll down to the bottom of the grid to check a certain result has appeared when I add it through a modal form (the UI test is currently failing as it can't see the result until I scroll down).
How do I target the scroll bar on the grid as opposed to the normal scroll bar on the main webpage? This is the HTML of my grid's scroll bar:
<div class="ScrollbarLayout_face ScrollbarLayout_faceVertical public_Scrollbar_face" style="height: 367.38px; transform: translate3d(0px, 148.535px, 0px); backface-visibility: hidden;"></div>I was thinking of using the below code, but I can't think how to target an element at the bottom of the grid to scroll to?
WebElement element = driver.findElement(By.id("my-id")); Actions actions = new Actions(driver); actions.moveToElement(element); actions.perform();最满意答案
首先使用任何事件将焦点设置为任何网格对象
driver.FindElement(By.XPath("/html/body/div[2]//table/tbody/tr[1]/td[1]")).Click();然后添加以下两行:
Actions actions = new Actions(driver); actions.SendKeys(OpenQA.Selenium.Keys.End).Build().Perform();First set focus to any object of grid by using any event
driver.FindElement(By.XPath("/html/body/div[2]//table/tbody/tr[1]/td[1]")).Click();Then add below two lines:
Actions actions = new Actions(driver); actions.SendKeys(OpenQA.Selenium.Keys.End).Build().Perform();更多推荐
发布评论