xpath

What does contains(., 'some text') refers to within xpath used in Selenium

梦想与她 提交于 2020-01-25 02:47:47
问题 I am new to selenium coding, and I am seeing several xpaths that contain (.,'followed by something') what does the ., refer to? 回答1: The . character within the xpath is the short form of text() As an example if an WebElement is represented within the DOM Tree as: <span>Use this payment method</span> Effective Locator Strategies will be: xpath 1 : //span[text()='Use this payment method'] xpath 2 : //span[contains(., 'Use this payment method')] Reference You can find a couple of relevant

Return number in array that is greater than X

旧街凉风 提交于 2020-01-25 02:20:31
问题 The following code automagically finds the highest price on a page: $vw_link = get_field('shop_link'); $ch = curl_init($vw_link); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $cl = curl_exec($ch); $dom = new DOMDocument(); @$dom->loadHTML($cl); $xpath = new DOMXpath($dom); $price = $xpath->query("//span[@class='price']"); foreach($price as $value) { $vw_array[] = floatval(str_replace('$', '', $value->nodeValue)); update_field('shop_price',max($vw_array)); } What would be the best thing

How to find child elements of a specific node ? with TinyXpath

走远了吗. 提交于 2020-01-25 02:12:34
问题 I have successfully used TinyXpath with root node as below const char* xpath ="/MyRoot/A/B"; TinyXpath::xpath_processor xp_proc(mRootElement, xpath); (this will find all B under all A of MyRoot) I wonder if I can pass non-root element to the constructor something like below const char* xpath = "./A/B"; TinyXpath::xpath_processor xp_proc(A_Element, xpath); (I want to find all B under specific A, when I have A_Element) Thank you 回答1: Given this constructor definition from the TinyXPath

XPATH: how get .length of 1st element group and .length of 2nd element group inside 1st group?

时间秒杀一切 提交于 2020-01-25 01:25:09
问题 I'm working with xml files having the structure set out below. <GroupType1> and <GroupType2> need to be processed separately. In either case, I want to loop through the <OperationEvent> elements in each <OperationStage> using XPATH. So, for each <GroupType1> , I need to get the number of <OperationStage> in <OperationStageCollection> , then get the number of <OperationEvent> in the <OperationEventCollection> of the current <OperationStage> . In pseudocode, the processing would be: For i = 1

IMPORTHTML or IMPORTXML to collect data from a site

て烟熏妆下的殇ゞ 提交于 2020-01-24 23:57:10
问题 I have made several attempts to collect the data within this table: The simple ways of the two functions I've commented on, I've tried, but not succeeded. I would like to if anyone knows any other way to collect this data in Google Sheets. Site Link: https://www.onlinebettingacademy.com/stats/team/brazil/operrio-pr/13217#tab=t_squad 回答1: the table you want to scrape is under JavaScript control, therefore, it can't be scraped. all you can get from that site into Google Sheets is: =ARRAY

FirePath not displaying HTML code after typing x-path

99封情书 提交于 2020-01-24 23:19:13
问题 Upon typing xpath in fire-path text field, if x-path is correct then it'll display the corresponding HTML code. It was working fine previously. But now it's not displaying the corresponding HTML code even though the xpath is correct. Can anyone help me to find the solution for this problem? I even uninstalled fire-path and installed again but still, it's not working. 回答1: If you visit the GitHub Page of FirePath, it clearly mentions that : FirePath is a Firebug extension that adds a

xpath that exclude some specific elements

随声附和 提交于 2020-01-24 22:10:26
问题 This is a simple version of the HTML of the page that I want analyse: <table class="class_1"> <tbody> <tr class="class_2"> <td class="class_3"> </td> <td class="class_4"> </td> <td class="class_5"> </td> </tr> <tr class="class_2"> <td class="class_3"> </td> <td class="class_4"> </td> <td class="class_5"><span class="class_6"></span>square</td> </tr> <tr class="class_2"> <td class="class_3"> </td> <td class="class_4"> </td> <td class="class_5"><span class="class_7"></span>circle</td> </tr> <tr

How to send text with in the username field within an iframe using Selenium VBA

五迷三道 提交于 2020-01-24 20:39:04
问题 I am attempting to login in the linked website. It looks straightforward and I have done this successfully in other websites. I can login manually. My code is Dim bot As New WebDriver bot.Start "chrome", "https://mbwebedi.mahle.com" bot.Get "/webedi/jsp/index.jsp" bot.FindElementByName("Login").SendKeys "ABC123" I receive the error: "NoSuchElementError Element not found for Name=Login" The element's text is: <input class="loginInput" type="text" name="Login" maxlength="30">` I can proceed

InvalidElementStateException when attempting to clear text through Selenium

痞子三分冷 提交于 2020-01-24 20:14:08
问题 The web application I am testing requires confirmation when deleting a record. I have created a test to enter in a valid reason for deleting this record. The code to do this is as follows: DeleteFieldButton. Click(); WaitMethods.WaitForElementToBeDisplayed(RemovalReason, 20); RemovalReason .Click(); RemovalReason .Clear(); RemovalReason .SendKeys("Automated Test - Delete Field"); The XPath to the text box is as follows: private Label RemovalReason = new Label(By.XPath("//*[@placeholder =

PHP XPath. How to return string with html tags?

假如想象 提交于 2020-01-24 15:59:45
问题 <?php libxml_use_internal_errors(true); $html = ' <html> <body> <div> Message <b>bold</b>, <s>strike</s> </div> <div> <span class="how"> <a href="link" title="text">Link</a>, <b> BOLD </b> </span> </div> </body> </html> '; $dom = new DOMDocument(); $dom->preserveWhiteSpace = false; $dom->strictErrorChecking = false; $dom->recover = true; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $messages = $xpath->query("//div"); foreach($messages as $message) { echo $message->nodeValue; } This