简体   繁体   English

在Selenium WebDriver中,如何找到具有DOM ID但没有className的元素?

[英]In Selenium WebDriver, how do I find an element with a DOM ID and no className?

The element I am trying to manipulate is a drop down autocomplete text box. 我尝试操作的元素是下拉自动填充文本框。 However rather than be a normal text box its this: 但是,这不是普通的文本框:

<input class="rad-input acInput float_left edScheduleList 
ui-autocomplete-input" style="width: 234px; font-size: 12px; 
font-family: Segoe UI, Arial, Times New Roman; padding-left: 4px; 
line-height: 12px;" placeholder="Select Schedule..." data-bind="click: _editorOverlay.Overlay.CustomRecVM.scheduleData.ac.dropdownArrowClick,
    enable: _editorOverlay.Overlay.CustomRecVM.scheduleEnabled,
    jqAuto: { autoFocus: true }, 
    jqAutoSource: editorOverlay.Overlay.CustomRecVM.scheduleData.list, 
    jqAutoQuery: editorOverlay.Overlay.CustomRecVM.scheduleData.GetList,
    jqAutoValue: _editorOverlay.Overlay.CustomRecVM.scheduleData.selectedID, 
    jqAutoSourceLabel: 'Text', 
    jqAutoSourceInputValue: 'Text', 
    jqAutoSourceValue: 'Value',
     jqChange: _editorOverlay.Overlay.CustomRecVM.ScheduleIndexChanged"    id="domId08015369399681067" autocomplete="off">

I can't find it by id, cssSelector, xpath, className, name, or class. 我无法通过id,cssSelector,xpath,className,名称或类找到它。 I have tried partial or containing text and am still getting no where. 我已经尝试过部分或包含文本,但仍然无法获取任何内容。 I am using Java for this. 我为此使用Java。

I found out I could just use cssSelector for the class name. 我发现我可以只使用cssSelector作为类名。 I am still relatively new to Selenium and did not know I could combine class names and cssSelector methods. 我对Selenium还是比较陌生,不知道我可以结合使用类名和cssSelector方法。 The above element can be manipulated with the following code: 可以使用以下代码来操纵上述元素:

driver.findElement(By.cssSelector
            ("input[class='rad-input acInput float_left edScheduleList ui-autocomplete-input']"));

Thanks for the help guys, the class name was really throwing me off. 谢谢你们的帮助,班级名称真的让我失望。 I thought because the selector was coming back as a dom I had to treat it differently. 我以为,因为选择器要作为dom回来,所以我不得不以不同的方式对待它。

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

相关问题 如何找到包含动态 id 和重复类名的元素? - How do I find an element that contains a dynamic id and repetitive classname? 如果我通过Selenium Webdriver和Java知道相应的文本,如何提取DOM元素的ID属性 - How to extract the ID attribute of a DOM element, if i know corresponding text through Selenium Webdriver and Java 如何在Selenium Webdriver(Java)中找到包含特定文本的元素? - How do I find an element that contains specific text in Selenium Webdriver (Java)? 使用selenium webdriver通过classname和tagname查找元素 - finding element by classname and tagname using selenium webdriver Selenium webdriver - 迭代,找到 webelement 然后点击它 - 我该怎么做? - Selenium webdriver - Iterate, find webelement and then click on it - how can I do that? 如何使用硒webdriver查找是否启用了元素? - How to find an element is enabled or not using selenium webdriver? 如何用selenium WebDriver找到文本字段的元素? - How to find element of textfield with selenium WebDriver? 如何在selenium webdriver中为java索引元素 - How to find an Element by index in selenium webdriver for java 如何在selenium webdriver中找到动态元素的Xpath - How to find Xpath for a dynamic element in selenium webdriver 我如何使用 DOM 定位器使用 selenium webdriver java 来定位 Web 元素 - How can i locate a web element by using DOM locator using selenium webdriver java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM