简体   繁体   English

如何使用 selenium java 单击未加载到 DOM 中的元素?

[英]How to click an element which is not loaded in DOM using selenium java?

There is div with many internal divs as seen in screenshot如屏幕截图所示,有许多内部 div 的 div

As seen in screenshot there are 6col and 1 checkbox col so total 7 columns are visble.如屏幕截图所示,有 6col 和 1 个复选框 col,因此总共 7 列是可见的。 But there are more columns till col40 if you scroll right.但是如果向右滚动,直到 col40 还会有更多列。 But the divs of all 40 cols are not loaded at one time but loads upon scrolling但是所有 40 列的 div 不是一次加载而是在滚动时加载

I want to validate if col35-col40(or any random col after col6) are visible and is editable and clickable.我想验证 col35-col40(或 col6 之后的任何随机 col)是否可见以及是否可编辑和可点击。

I have tried below options but none of them working.我尝试了以下选项,但没有一个工作。

  1. Javascript executor (with or without webelement for scrolling horizontally) Javascript 执行器(带有或不带有用于水平滚动的 webelement)
  2. Robot keys.tab/keys.cntrl+keys.end/all keys option using which we can manually go to that particular column Robot keys.tab/keys.cntrl+keys.end/all keys 选项使用它我们可以手动转到该特定列
  3. Sendkeys发送键
  4. Action class动作类
  5. Zoom out (this is not the feasible/ correct way to do but still tried but this is also not working as expected)缩小(这不是可行/正确的方法,但仍然尝试过,但这也没有按预期工作)

Need some solution for this.需要一些解决方案。

Please note: The scroll bar is not having any identifier/attribute but it is inside the main div without any unique identity.请注意:滚动条没有任何标识符/属性,但它位于主 div 内,没有任何唯一标识。

If your element is not loaded yet in DOM, you cannot perform any actions on it since is not there.如果您的元素尚未在 DOM 中加载,您将无法对其执行任何操作,因为它不存在。 A workaround for your problem is to design a method to scroll until your element is available in DOM, and then perform desired actions (check, click etc).您的问题的解决方法是设计一种滚动方法,直到您的元素在 DOM 中可用,然后执行所需的操作(检查、单击等)。 Note that you cannot scroll to your element (because is not there) so you can scroll to another reference (locator) or based on pixels using javascript executor object.请注意,您无法滚动到您的元素(因为不存在),因此您可以使用 javascript 执行程序对象滚动到另一个参考(定位器)或基于像素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我们登陆页面时如何点击 DOM 上不可用的元素。 JAVA + Selenium 自动化 - How to click on element which is not available on DOM when we land on the page. JAVA + Selenium Automation 如何使用 Selenium 和 Java 单击与 HTML DOM 中的相邻元素相关的元素 - How to click an element with respect to the adjacent element within the HTML DOM using Selenium and Java 使用Selenium WebDriver java单击动态加载页面的元素 - Click on element of a dynamic loaded page using Selenium WebDriver java Selenium java:如何知道WebElement指向哪个DOM元素? - Selenium java: how to know which DOM element is pointed by a WebElement? 如何通过 Java 使用 Selenium 单击元素 - How to click on the element using Selenium through Java 如何在 selenium 中使用 java 单击元素? - How to click element using java in selenium? Selenium,Java-如何使用文本单击元素? - Selenium, Java - How to click at an element using text? 如何使用Java检查DOM上的元素是否在Selenium中的前台? - How to check whether an element on the DOM is in the foreground in Selenium using Java? 在使用Selenium和Java将鼠标悬停在ebay.com中的元素上之后,如何单击可见的元素 - How to click on an element which is visible after mouse hover over an element within ebay.com using Selenium and Java 如何从 Selenium Java 中删除 DOM 元素 - How to delete DOM element from Selenium Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM