久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Java Selenium webdriver表達(dá)式通過ccs查找以開頭和結(jié)尾

Java Selenium webdriver expression finding dynamic element by ccs that starts with and ends with(Java Selenium webdriver表達(dá)式通過ccs查找以開頭和結(jié)尾的動態(tài)元素)
本文介紹了Java Selenium webdriver表達(dá)式通過ccs查找以開頭和結(jié)尾的動態(tài)元素的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我需要找到以下 HTML 元素.現(xiàn)在,這個(gè)id"name 是動態(tài)的,就像 int 0";最后會改變,但我知道它會是什么.0-0"中的第一個(gè) int也會改變,但會是什么都無所謂.

我嘗試了下面的代碼來查找以#ui-select-choices-row-"開頭的元素.并以所需的int"輸入結(jié)束,但沒有按預(yù)期找到它.關(guān)于我在這里做錯(cuò)了什么有什么建議嗎?

嘗試 1:

driver.findElement(By.cssSelector("div[id^='#ui-select-choices-row-'] 和 div[id$='"+int+"div']"));

嘗試 2:

driver.findElement(By.cssSelector("div[id^='ui-select-choices-row-'] and div[id$='"+int+"']"));

解決方案

你已經(jīng)足夠接近了.您需要將 id 開頭的 # 刪除為 # 本身表示 id 屬性.


動態(tài) CSS_SELECTOR 的解釋

要僅考慮 hrefdata-drupal-link-system-path 屬性的靜態(tài)部分,您可以在 css-selectors:

  • $ :表示一個(gè)屬性值

    結(jié)尾
  • ^ : 表示一個(gè)屬性值

    開頭

所以最細(xì)粒度的 css_selector 應(yīng)該是:

div[id^='ui-select-choices-row-'][id$='"+count+ "']


解決方案

您的有效代碼行將是:

driver.findElement(By.cssSelector("div[id^='ui-select-choices-row-'][id$='"+count+"']"));

注意:int為關(guān)鍵字,變量名使用其他名稱.


參考文獻(xiàn)

您可以在以下位置找到一些相關(guān)的詳細(xì)討論:

  • 通過 CSS 選擇器查找元素在 Python 中使用 ChromeDriver (Selenium)
  • 如何在通過 Selenium 和 Python 實(shí)現(xiàn)自動化的同時(shí)使用 xpath/css 選擇器在 drupal 8 網(wǎng)站中單擊動態(tài)鏈接
  • 如何使用 Selenium 和 Python 獲取內(nèi)部具有動態(tài)部分的選擇器?

I have the below HTML element that I need to find. Now, this "id" name is dynamic in the way that the int "0" at the end will change, but I know what it will be. The first int in "0-0" will also change, but it doesn't matter what it will be.

<div id="ui-select-choices-row-0-0">

I've tried the below code that looks for an element that starts with "#ui-select-choices-row-" and ends with the desired input of "int", but it's not finding it as expected. Any suggestions on what I'm doing wrong here?

Attempt 1:

driver.findElement(By.cssSelector("div[id^='#ui-select-choices-row-'] and div[id$='"+int+" div']"));

Attempt 2:

driver.findElement(By.cssSelector("div[id^='ui-select-choices-row-'] and div[id$='"+int+"']"));

解決方案

You were close enough. You need to remove the # from the beginning of the id as # itself denotes the id attribute.


Explanation of the dynamic CSS_SELECTOR

To consider only the static part of href and data-drupal-link-system-path attributes you can use the following wildcards in css-selectors:

  • $ : To indicate an attribute value ends with

  • ^ : To indicate an attribute value starts with

So the most granular css_selector would be :

div[id^='ui-select-choices-row-'][id$='" +count+ "']


Solution

Your effective line of code will be:

driver.findElement(By.cssSelector("div[id^='ui-select-choices-row-'][id$='" +count+ "']"));

Note: int is a keyword, use other names as the variable name.


References

You can find a couple of relevant detailed discussions in:

  • Finding elements by CSS selector with ChromeDriver (Selenium) in Python
  • How to click a dynamic link with in a drupal 8 website using xpath/css selector while automating through Selenium and Python
  • How to get selectors with dynamic part inside using Selenium with Python?

這篇關(guān)于Java Selenium webdriver表達(dá)式通過ccs查找以開頭和結(jié)尾的動態(tài)元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環(huán)繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數(shù)據(jù)庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 成人免费黄色大片 | 久久精品av| 性生活毛片 | 久久er99热精品一区二区 | 成人小网站 | 黄色小视频免费观看 | 国产91精品在线观看 | 国产av毛片 | 成人在线视频播放 | 欧美理论片在线观看 | 午夜免费福利视频 | 91综合网| 黄色免费在线看 | 综合色av | 伊人av综合 | 欧美日韩国产精品 | 国产www在线观看 | 三级福利视频 | 波多野结衣之双调教hd | 亚洲免费小视频 | 日本xxxx69 | 亚洲天堂网在线观看 | 一区二区三区中文字幕 | 国产精品乱码一区二区视频 | 亚洲国产精品视频 | 在线伊人网| 91精品国产日韩91久久久久久 | 成人免费毛片片v | 一区二区三区免费观看 | 亚洲另类自拍 | 精品国产一区二 | 亚洲无av在线中文字幕 | 国产精品久久 | 欧美一级特黄视频 | 午夜精品国产精品大乳美女 | 日韩精品不卡 | 少妇一级淫片免费看 | 久久这里都是精品 | 国产又粗又猛又黄又爽无遮挡 | 日日夜夜操操 | 日本精品在线视频 |