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

    1. <i id='eEjOZ'><tr id='eEjOZ'><dt id='eEjOZ'><q id='eEjOZ'><span id='eEjOZ'><b id='eEjOZ'><form id='eEjOZ'><ins id='eEjOZ'></ins><ul id='eEjOZ'></ul><sub id='eEjOZ'></sub></form><legend id='eEjOZ'></legend><bdo id='eEjOZ'><pre id='eEjOZ'><center id='eEjOZ'></center></pre></bdo></b><th id='eEjOZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eEjOZ'><tfoot id='eEjOZ'></tfoot><dl id='eEjOZ'><fieldset id='eEjOZ'></fieldset></dl></div>

      1. <legend id='eEjOZ'><style id='eEjOZ'><dir id='eEjOZ'><q id='eEjOZ'></q></dir></style></legend><tfoot id='eEjOZ'></tfoot>

        <small id='eEjOZ'></small><noframes id='eEjOZ'>

          <bdo id='eEjOZ'></bdo><ul id='eEjOZ'></ul>

        如何通過除“類"之外的屬性直接找到 WebEle

        How to directly find WebElements by their attributes except quot;classquot; and quot;namequot; (for example quot;titlequot;)(如何通過除“類之外的屬性直接找到 WebElements和“名稱(例如“標題)) - IT屋-程序員軟件開發

          • <tfoot id='QY0pD'></tfoot>
                <tbody id='QY0pD'></tbody>

                <i id='QY0pD'><tr id='QY0pD'><dt id='QY0pD'><q id='QY0pD'><span id='QY0pD'><b id='QY0pD'><form id='QY0pD'><ins id='QY0pD'></ins><ul id='QY0pD'></ul><sub id='QY0pD'></sub></form><legend id='QY0pD'></legend><bdo id='QY0pD'><pre id='QY0pD'><center id='QY0pD'></center></pre></bdo></b><th id='QY0pD'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='QY0pD'><tfoot id='QY0pD'></tfoot><dl id='QY0pD'><fieldset id='QY0pD'></fieldset></dl></div>

                <legend id='QY0pD'><style id='QY0pD'><dir id='QY0pD'><q id='QY0pD'></q></dir></style></legend>

                <small id='QY0pD'></small><noframes id='QY0pD'>

                • <bdo id='QY0pD'></bdo><ul id='QY0pD'></ul>
                  本文介紹了如何通過除“類"之外的屬性直接找到 WebElements和“名稱"(例如“標題")的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我是 Java 和 Selenium 的新手,所以如果我的問題聽起來有點初級,我提前道歉.

                  我使用:

                  driverChrome.findElements(By.className("blabla"));

                  查找以blabla"作為其類名的元素,例如:

                  <span class="blabla" title="標題">...</span>

                  現在,如果我想通過其他屬性查找所有元素怎么辦?類似:

                  driverChrome.findElements(By.titleValue("the title"));

                  這是我目前用于執行此任務的代碼:

                  列表spans = driverChrome.findElements(By.tagName("span"));for (WebElement we : spans) {if (we.getAttribute("title") != null) {if (we.getAttribute("title").equals("the title")) {...休息;}}}

                  但它并不快速且易于使用.

                  解決方案

                  XPath

                  歸檔元素有很多方法

                  1 絕對路徑

                  <html><身體>

                  <表格><輸入 id="demo"/></表格></div></身體><html>

                  獲取輸入"標簽

                  xpath="/html/body/div/form/input"

                  2 相對路徑

                  <html><身體>

                  <表格><輸入 id="demo"/></表格></div></身體><html>

                  獲取輸入"標簽

                  xpath="http://輸入"

                  3 索引

                  <html><身體>

                  <表格><輸入id="demo1"/><輸入id="demo2"></表格></div></身體><html>

                  獲取輸入'demo2'

                  xpath="http://輸入[1]"

                  4 任意單個屬性

                  <html><身體>

                  <表格><輸入id="demo1"/><輸入 id="demo2" foo="bar"></表格></div></身體><html>

                  獲取輸入'demo2'

                  xpath="http://input[@id='demo2']" (相當于By.id)

                  或者

                  xpath="http://input[@foo='bar']"

                  5 任意多個屬性

                  <html><身體>

                  <表格><輸入id="1" type="提交"/><輸入 id="2" foo="bar"/><input id="3" type="submit" foo="bar"/></表格></div></身體><html>

                  獲取第三個輸入

                  xpath="http://input[@type='submit'][@foo='bar']"

                  或者

                  xpath="http://input[@type='submit' and @foo='bar']"

                  如果在這里使用 xpath="http://input[@type='submit' 或 @foo='bar']" 你會得到一個數組.您可以通過 driver.findElements(By.xpath(xpath)) (java) 獲取列表.否則你會得到第一個元素(如果你只使用 driver.findElement).因為所有 3 個輸入元素都滿足您的條件或",它給了您第一個.

                  6 包含屬性

                  <html><身體>

                  <表格><輸入id="1" type="提交"/><input id="2" foo="bar" daddy="dog"/><input id="3" type="submit" foo="bar"/></表格></div></身體><html>

                  獲取第二個輸入

                  xpath="http://input[@daddy]"

                  因為只有第二個有屬性'daddy'

                  7 內搜索

                   <html><身體>

                  <表格><input id="input1" daddy="dog"/><input id="input2" daddy="pig"/></表格></div>

                  <表格><input id="input3" daddy="dog"/><input id="input4" daddy="apple"/></表格></div></身體><html>

                  獲取第二個div

                  xpath="http://div[.//input[@daddy='dog'] 和 .//input[@daddy='apple']]"

                  總的來說,這些都是我現在可以解決的.希望對您有所幫助.

                  I am very new at Java and Selenium so my apologies in advance if my question sounds a bit primary.

                  I use:

                  driverChrome.findElements(By.className("blabla"));
                  

                  to find elements which have "blabla" as their className, for example:

                  <span class="blabla" title="the title">...</span>
                  

                  Now, what if I want to find all elements by their other attributes? something like:

                  driverChrome.findElements(By.titleValue("the title"));
                  

                  This is the code that I am currently using to do this task:

                  List<WebElement> spans = driverChrome.findElements(By.tagName("span"));
                  
                  for (WebElement we : spans) {
                  
                      if (we.getAttribute("title") != null) {
                              if (we.getAttribute("title").equals("the title")) {
                                      ...
                                      break;
                              }
                      }
                  
                  }
                  

                  but it is not fast and easy to use.

                  解決方案

                  There are many methods while archiving an element by XPath

                  1 Absolutely path

                  <html>
                    <body>
                       <div>
                         <form>
                            <input id="demo"/>
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get the 'input' tag

                  xpath="/html/body/div/form/input"
                  

                  2 Relative path

                  <html>
                    <body>
                       <div>
                         <form>
                            <input id="demo"/>
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get the 'input' tag

                  xpath="http://input"  
                  

                  3 Index

                  <html>
                    <body>
                       <div>
                         <form>
                            <input id="demo1"/>
                            <input id="demo2"> 
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get the input 'demo2'

                  xpath="http://input[1]"

                  4 Arbitrary single attribute

                  <html>
                    <body>
                       <div>
                         <form>
                            <input id="demo1"/>
                            <input id="demo2" foo="bar"> 
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get input 'demo2'

                  xpath="http://input[@id='demo2']" (equivalent to By.id)
                  

                  Or

                  xpath="http://input[@foo='bar']"
                  

                  5 Arbitrary multiple attributes

                  <html>
                      <body>
                       <div>
                         <form>
                            <input id="1" type="submit" />
                            <input id="2" foo="bar"/>
                            <input id="3" type="submit" foo="bar"/> 
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get 3rd input

                  xpath="http://input[@type='submit'][@foo='bar']"
                  

                  Or

                  xpath="http://input[@type='submit' and @foo='bar']"
                  

                  If use xpath="http://input[@type='submit' or @foo='bar']" here you'll get an array. You can get the List by driver.findElements(By.xpath(xpath)) (java). Otherwise you'll get the first element(If you just use driver.findElement). Because all of the 3 input elements meet your condition 'or' and it gives you the first one.

                  6 Contains attribute

                  <html>
                      <body>
                       <div>
                         <form>
                            <input id="1" type="submit" />
                            <input id="2" foo="bar" daddy="dog"/>
                            <input id="3" type="submit" foo="bar"/> 
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get the second input

                  xpath="http://input[@daddy]"
                  

                  Because only the second one has attribute 'daddy'

                  7 Inner searching

                   <html>
                      <body>
                       <div>
                         <form>
                            <input id="input1" daddy="dog" />
                            <input id="input2" daddy="pig"/>
                         </form>
                       </div>
                       <div>
                         <form>
                            <input id="input3" daddy="dog" />
                            <input id="input4" daddy="apple"/>
                         </form>
                       </div>
                     </body>
                   <html>
                  

                  To get the second div

                  xpath="http://div[.//input[@daddy='dog'] and .//input[@daddy='apple']]"
                  

                  Overall those are all I can work out for now. Hope it helps.

                  這篇關于如何通過除“類"之外的屬性直接找到 WebElements和“名稱"(例如“標題")的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)

                  <small id='9Ffx6'></small><noframes id='9Ffx6'>

                    <tbody id='9Ffx6'></tbody>
                  <tfoot id='9Ffx6'></tfoot>
                  <i id='9Ffx6'><tr id='9Ffx6'><dt id='9Ffx6'><q id='9Ffx6'><span id='9Ffx6'><b id='9Ffx6'><form id='9Ffx6'><ins id='9Ffx6'></ins><ul id='9Ffx6'></ul><sub id='9Ffx6'></sub></form><legend id='9Ffx6'></legend><bdo id='9Ffx6'><pre id='9Ffx6'><center id='9Ffx6'></center></pre></bdo></b><th id='9Ffx6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9Ffx6'><tfoot id='9Ffx6'></tfoot><dl id='9Ffx6'><fieldset id='9Ffx6'></fieldset></dl></div>

                        <bdo id='9Ffx6'></bdo><ul id='9Ffx6'></ul>

                        <legend id='9Ffx6'><style id='9Ffx6'><dir id='9Ffx6'><q id='9Ffx6'></q></dir></style></legend>
                            主站蜘蛛池模板: 亚洲美乳中文字幕 | 日本精品视频在线观看 | 无毛av | 久久伊人一区二区 | 欧美成人免费在线视频 | 欧美日韩综合一区 | 激情一区二区三区 | 性一区 | 亚洲一区二区久久 | 日韩欧美久久精品 | gogo肉体亚洲高清在线视 | 午夜影院在线观看 | 日韩精品免费一区二区在线观看 | a级黄色片在线观看 | 久久精品国产免费看久久精品 | 国产一区二区电影网 | 热久久999 | 午夜影院黄| 久久国产精品一区二区三区 | 国产精品一区二 | 黄色一级片aaa | 91偷拍精品一区二区三区 | 久久免费大片 | av中文字幕在线观看 | 草草草久久久 | 亚洲天堂精品久久 | 亚洲激情综合 | 亚洲精品国产综合区久久久久久久 | 日韩毛片在线观看 | 色综合天天网 | 精品日韩在线观看 | 日韩在线 | 国产乱码一二三区精品 | 日韩欧美在线视频 | 一区二区三区在线看 | 日韩欧美一级精品久久 | 成人一区二区三区视频 | 成年人在线观看 | 国产精品不卡一区 | 国产伦精品一区二区三区高清 | 亚洲综合无码一区二区 |