久久久久久久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屋-程序員軟件開發(fā)

          • <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>

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

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

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

                  列表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']" 你會得到一個數(shù)組.您可以通過 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 內(nèi)搜索

                   <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']]"

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

                  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.

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

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?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毛片 | 日本美女毛茸茸 | 午夜激情网 | 色综合天天综合网国产成人网 | 中文字幕免费在线观看 | 最新av在线 | 欧美国产精品一区二区 | 操操操日日日 | 91高清国产 | 韩国av免费 | 三上悠亚一区 | 天堂99| 黄色小说视频网站 | 黄色影视 | 久久久久九九九 | 天天插天天狠天天透 | 国产在线黄色 | 成人在线观看网站 | 成人国产精品免费观看 | 国产wwwwww | 亚洲第一毛片 | www亚洲精品 | 免费国产黄色 | 九九免费视频 | 亚洲成肉网| 国产区一区二区 | 一区二区三区在线看 | 亚洲高清在线视频 | 国产精品三| 欧美日韩精品一区 | 亚洲一区久久 | 中文在线视频 | 国产不卡一区 | 精品一区二区三区免费看 | 成人免费网站 | 高潮毛片无遮挡免费看 |