xpath 相关问题

XPath的主要目的是解决XML文档的各个部分。它还提供操纵弦乐,数字和布尔值的基本设施。 XPath使用紧凑的非XML语法。 XPath在XML文档的抽象逻辑结构上运行,而不是表面语法。

XPath 语法的官方规范在哪里?

我想编写一个函数,它可以独立于任何 XML/HTML 简单地验证 XPath 表达式的语法(因此它会捕获 //p[text(}="Hello"] 等有拼写错误的内容),但是...

回答 2 投票 0

是否可以仅合并通过 xinclude 添加到 XML 的元素的一部分?

我有一个 XInclude,我正在将其合并到我的 XML 中,以便不必重复内容。这对于我的大多数用途都很有效,但在特定情况下,对象略有不同。那个...

回答 1 投票 0

为什么selenium无法使用xpath或css选择器找到要单击的元素?

我尝试单击此处页面上的“>”,但 chrome XPATH 或 CSS 选择器找不到它 https://theanalyst.com/na/2023/08/opta-football-predictions/ 应该 chrome 完整的 xpath...

回答 1 投票 0

将 XPATH 选择器拆分为 WebdriverIO 中的节点

这是一个很简单的问题,但我还没有弄清楚如何将选择器拆分为节点元素以提高性能。我正在研究 Windows 桌面应用程序的测试自动化。 让我们...

回答 1 投票 0

Seleniumbase 消息:元素 <p> 无法通过键盘访问

我正在尝试进入以下文本区域 但我得到了错误 消息:键盘无法访问元素 我都尝试过 元素 = WebDriverWait(驱动程序, 20).until(EC. 我正在尝试进入以下文本区域 但我收到错误 Message: Element <p> is not reachable by keyboard 我都尝试过 element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".ql-editor p"))).send_keys(troll_list[rand_troll]) 和 wait = WebDriverWait(driver, 30) wait.until(EC.element_to_be_clickable((By.XPATH, "//*[@id='chat_send-form_textarea']/div[1]/div[1]/p"))).send_keys(troll_list[rand_troll]) 我也遇到同样的错误 如何使用 seleniumbase 访问此文本框? 我正在使用 Firefox 驱动程序。 更新: 此行为仅发生在 Firefox 中。 Chromium 能够成功找到并选择文本框。 您正在尝试将文本输入到p(段落)HTML 标记中,但该标记并非为此目的而设计。 您应该找到适当的 <input type="text"> 元素或 <textarea>... 将 div 添加到 css 选择器路径。 element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.ql-editor p"))).send_keys(troll_list[rand_troll]) 使用CSS选择器时,在CSS路径前添加标签名称

回答 2 投票 0

XPath 不适用于在 XML 中进行选择

我有一个 XML 文档,但我一生都无法使用 XPath 获取数据。我尝试了所有能找到的样本,但没有成功。我正在尝试提取电子邮件地址。有什么想法吗? XML: &...

回答 2 投票 0

如何使用 XPATH 使用 Selenium for Python 来截取网页元素的屏幕截图?

我正在尝试使用 Python 自动从在线 Power BI 报告中截取屏幕截图。我决定使用 By.XPATH 方法来查找正确的元素,但我遇到了一些困难。这里是...

回答 1 投票 0

在c#中使用XPath删除xml标签

我想使用 C# 从现有 XML 文件中删除一些标签。我的 XML 内容如下: 我想使用 C# 从现有 XML 文件中删除一些标签。我的 XML 内容如下: <?xml version="1.0" encoding="utf-8"?> <Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"> <ext:UBLExtensions> <ext:UBLExtension> <ext:ExtensionURI>urn:oasis:names:specification:ubl:dsig:enveloped:xades</ext:ExtensionURI> <ext:ExtensionContent> <sig:UBLDocumentSignatures xmlns:sig="urn:oasis:names:specification:ubl:schema:xsd:CommonSignatureComponents-2" xmlns:sac="urn:oasis:names:specification:ubl:schema:xsd:SignatureAggregateComponents-2" xmlns:sbc="urn:oasis:names:specification:ubl:schema:xsd:SignatureBasicComponents-2"> <sac:SignatureInformation> <cbc:ID>urn:oasis:names:specification:ubl:signature:1</cbc:ID> <sbc:ReferencedSignatureID>urn:oasis:names:specification:ubl:signature:Invoice</sbc:ReferencedSignatureID> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="signature"> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2006/12/xml-c14n11" /> <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha256" /> <ds:Reference Id="invoiceSignedData" URI=""> <ds:Transforms> <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"> <ds:XPath>not(//ancestor-or-self::ext:UBLExtensions)</ds:XPath> </ds:Transform> <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"> <ds:XPath>not(//ancestor-or-self::cac:Signature)</ds:XPath> </ds:Transform> <ds:Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"> <ds:XPath>not(//ancestor-or-self::cac:AdditionalDocumentReference[cbc:ID='QR'])</ds:XPath> </ds:Transform> <ds:Transform Algorithm="http://www.w3.org/2006/12/xml-c14n11" /> </ds:Transforms> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> <ds:DigestValue>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxJbnZva</ds:DigestValue> </ds:Reference> <ds:Reference Type="http://www.w3.org/2000/09/xmldsig#SignatureProperties" URI="#xadesSignedProperties"> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> <ds:DigestValue>Y2ZhM2ExNDEwYTNmODA1ZDc3MjVlMWMxYWUzMzIyZDFmZDIyZjhmMmU5YzM1MDgwMzE1YmIwODQ5ZTMzN2ZkOQ==</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue>MEUCIQChDLnZWprmUoLQLIEU5Z7LNlStc1MCCsgPgdrR6513ZgIgdxkNg/1Di92EcYIiamg9d6achtxfqQyxYn5mCdo4BgA=</ds:SignatureValue> <ds:KeyInfo> <ds:X509Data> <ds:X509Certificate>MIID2zCCA4CgAwIBAgITbwAAdqDmIhqsjpm5CwABAAB2oDAKBggqhkjOPQQDA</ds:X509Certificate> </ds:X509Data> </ds:KeyInfo> <ds:Object> <xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="signature"> <xades:SignedProperties Id="xadesSignedProperties"> <xades:SignedSignatureProperties> <xades:SigningTime>2023-12-28T21:36:34Z</xades:SigningTime> <xades:SigningCertificate> <xades:Cert> <xades:CertDigest> <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /> <ds:DigestValue>YjcyNzI4NWZiN2FlNzI1NTQxOGIzZGY1ZWY4MDc2N2JkMDIyMDM5ZDU5YjJmNWRkOTQ5YTZkMDU2YjEzYzJkZA==</ds:DigestValue> </xades:CertDigest> <xades:IssuerSerial> <ds:X509IssuerName>CN=TSZEINVOICE-SubCA-1, DC=extgazt, DC=gov, DC=local</ds:X509IssuerName> <ds:X509SerialNumber>2475382886904809774818644480820936050208702411</ds:X509SerialNumber> </xades:IssuerSerial> </xades:Cert> </xades:SigningCertificate> </xades:SignedSignatureProperties> </xades:SignedProperties> </xades:QualifyingProperties> </ds:Object> </ds:Signature> </sac:SignatureInformation> </sig:UBLDocumentSignatures> </ext:ExtensionContent> </ext:UBLExtension> </ext:UBLExtensions> <cbc:ProfileID>reporting:1.0</cbc:ProfileID> <cbc:ID>1-256559</cbc:ID> <cbc:UUID>f69ff49a-3f26-4561-8c46-b85097b1cf2a</cbc:UUID> <cbc:IssueDate>2023-07-28</cbc:IssueDate> <cbc:IssueTime>16:29:07</cbc:IssueTime> <cbc:InvoiceTypeCode name="0100000">388</cbc:InvoiceTypeCode> <cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode> <cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode> <cac:AdditionalDocumentReference> <cbc:ID>ICV</cbc:ID> <cbc:UUID>1</cbc:UUID> </cac:AdditionalDocumentReference> <cac:AdditionalDocumentReference> <cbc:ID>PIH</cbc:ID> <cac:Attachment> <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain">NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==</cbc:EmbeddedDocumentBinaryObject> </cac:Attachment> </cac:AdditionalDocumentReference> <cac:AdditionalDocumentReference> <cbc:ID>QR</cbc:ID> <cac:Attachment> <cbc:EmbeddedDocumentBinaryObject mimeCode="text/plain"> </cbc:EmbeddedDocumentBinaryObject> </cac:Attachment> </cac:AdditionalDocumentReference> <cac:Signature> <cbc:ID>urn:oasis:names:specification:ubl:signature:Invoice</cbc:ID> <cbc:SignatureMethod>urn:oasis:names:specification:ubl:dsig:enveloped:xades</cbc:SignatureMethod> </cac:Signature> <cac:AccountingSupplierParty> <cac:Party> <cac:PartyIdentification> <cbc:ID schemeID="CRN"> </cbc:ID> </cac:PartyIdentification> <cac:PostalAddress> <cbc:StreetName> </cbc:StreetName> <cbc:BuildingNumber> </cbc:BuildingNumber> <cbc:CitySubdivisionName> </cbc:CitySubdivisionName> <cbc:CityName> </cbc:CityName> <cbc:PostalZone> </cbc:PostalZone> <cac:Country> <cbc:IdentificationCode>SA</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyTaxScheme> <cbc:CompanyID>311380797100003</cbc:CompanyID> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:PartyTaxScheme> <cac:PartyLegalEntity> <cbc:RegistrationName>LAMARA SUPERMARKET</cbc:RegistrationName> </cac:PartyLegalEntity> </cac:Party> </cac:AccountingSupplierParty> <cac:AccountingCustomerParty> <cac:Party> <cac:PartyIdentification> <cbc:ID schemeID="NAT"> </cbc:ID> </cac:PartyIdentification> <cac:PostalAddress> <cbc:StreetName> </cbc:StreetName> <cbc:BuildingNumber> </cbc:BuildingNumber> <cbc:CitySubdivisionName> </cbc:CitySubdivisionName> <cbc:CityName> </cbc:CityName> <cbc:PostalZone> </cbc:PostalZone> <cac:Country> <cbc:IdentificationCode>SA</cbc:IdentificationCode> </cac:Country> </cac:PostalAddress> <cac:PartyTaxScheme> <cbc:CompanyID> </cbc:CompanyID> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:PartyTaxScheme> <cac:PartyLegalEntity> <cbc:RegistrationName>CASH ACCOUNT</cbc:RegistrationName> </cac:PartyLegalEntity> </cac:Party> </cac:AccountingCustomerParty> <cac:Delivery> <cbc:ActualDeliveryDate>2023-07-28</cbc:ActualDeliveryDate> </cac:Delivery> <cac:PaymentMeans> <cbc:PaymentMeansCode>10</cbc:PaymentMeansCode> </cac:PaymentMeans> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> <cac:TaxCategory> <cbc:ID schemeID="UN/ECE 5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:AllowanceCharge> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">4.56</cbc:TaxAmount> </cac:TaxTotal> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">4.56</cbc:TaxAmount> <cac:TaxSubtotal> <cbc:TaxableAmount currencyID="SAR">30.39</cbc:TaxableAmount> <cbc:TaxAmount currencyID="SAR">4.56</cbc:TaxAmount> <cac:TaxCategory> <cbc:ID schemeID="UN/ECE 5305" schemeAgencyID="6">S</cbc:ID> <cbc:Percent>15.00</cbc:Percent> <cac:TaxScheme> <cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6">VAT</cbc:ID> </cac:TaxScheme> </cac:TaxCategory> </cac:TaxSubtotal> </cac:TaxTotal> <cac:LegalMonetaryTotal> <cbc:LineExtensionAmount currencyID="SAR">30.39</cbc:LineExtensionAmount> <cbc:TaxExclusiveAmount currencyID="SAR">30.39</cbc:TaxExclusiveAmount> <cbc:TaxInclusiveAmount currencyID="SAR">34.95</cbc:TaxInclusiveAmount> <cbc:AllowanceTotalAmount currencyID="SAR">0.00</cbc:AllowanceTotalAmount> <cbc:PrepaidAmount currencyID="SAR">0.00</cbc:PrepaidAmount> <cbc:PayableAmount currencyID="SAR">34.95</cbc:PayableAmount> </cac:LegalMonetaryTotal> <cac:InvoiceLine> <cbc:ID>1</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">1.00</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">0.15</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">1.15</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name> </cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">1.00</cbc:PriceAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>2</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">2.00</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">0.30</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">2.30</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name> </cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">2.00</cbc:PriceAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>3</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">8.26</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">1.24</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">9.50</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name> </cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">8.26</cbc:PriceAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>4</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">5.22</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">0.78</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">6.00</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name> </cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">5.22</cbc:PriceAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>5</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">1.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">0.87</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">0.13</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">1.00</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name>ABCD</cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>R15</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">0.87</cbc:PriceAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine> <cac:InvoiceLine> <cbc:ID>6</cbc:ID> <cbc:InvoicedQuantity unitCode="PCE">2.00</cbc:InvoicedQuantity> <cbc:LineExtensionAmount currencyID="SAR">13.04</cbc:LineExtensionAmount> <cac:TaxTotal> <cbc:TaxAmount currencyID="SAR">1.96</cbc:TaxAmount> <cbc:RoundingAmount currencyID="SAR">15.00</cbc:RoundingAmount> </cac:TaxTotal> <cac:Item> <cbc:Name> </cbc:Name> <cac:ClassifiedTaxCategory> <cbc:ID>S</cbc:ID> <cbc:Percent>15</cbc:Percent> <cac:TaxScheme> <cbc:ID>VAT</cbc:ID> </cac:TaxScheme> </cac:ClassifiedTaxCategory> </cac:Item> <cac:Price> <cbc:PriceAmount currencyID="SAR">6.52</cbc:PriceAmount> <cac:AllowanceCharge> <cbc:ChargeIndicator>false</cbc:ChargeIndicator> <cbc:AllowanceChargeReason>discount</cbc:AllowanceChargeReason> <cbc:Amount currencyID="SAR">0.00</cbc:Amount> </cac:AllowanceCharge> </cac:Price> </cac:InvoiceLine> </Invoice> 从上面的 XML 中,我想删除标签“UBLExtensions”、“cac:AdditionalDocumentReference”(带有 QR 元素)、“cac:Signature”。 我尝试了其他类似问题中讨论的不同方法,但无法得到正确的解决方案。我只想用 XPath 删除它,否则文件的哈希值会改变。 我尝试过的代码之一如下: var xmlDoc = XDocument.Load(Server.MapPath("~/XML/311380797100003_20230728T162907_1-256559.xml")); var element = ( from x in xmlDoc.Root.Elements("Invoice") where x.Element("tage-name").Value == "ext:UBLExtensions" select x ).FirstOrDefault(); element.Remove(); xmlDoc.Save(Server.MapPath("~/XML/311380797100003_20230728T162907_1-256559.xml")); 但是在这里,这段代码给出了错误,因为我不知道如何使用它。 尝试以下操作: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; namespace ConsoleApp10 { class Program { const string INPUT_FILENAME = @"c:\temp\test.xml"; const string OUTPUT_FILENAME = @"c:\temp\test1.xml"; static void Main(string[] args) { XDocument doc = XDocument.Load(INPUT_FILENAME); XNamespace extNs = doc.Root.GetNamespaceOfPrefix("ext"); XNamespace cacNs = doc.Root.GetNamespaceOfPrefix("cac"); XNamespace cbcNs = doc.Root.GetNamespaceOfPrefix("cbc"); XElement ublExt = doc.Descendants(extNs + "UBLExtensions").FirstOrDefault(); ublExt.Remove(); var qr = doc.Descendants(cacNs + "AdditionalDocumentReference").Where(x => (string)x.Element(cbcNs + "ID") == "QR"); qr.Remove(); XElement signature = doc.Descendants(cacNs + "Signature").FirstOrDefault(); signature.Remove(); doc.Save(OUTPUT_FILENAME); } } }

回答 1 投票 0

使用 xPath(javascript, jquery) 从 url 链接解析 html 页面

我对 Javascript/jQuery 真的很陌生。我之前用 Objective-C 和 Swift 编写过代码,并且可以使用 XPath 和 Hpple 之类的框架来解析 (x)html 网站。 现在我必须做点什么

回答 4 投票 0

使用正确的代码拉动 td/html 元素 - Selenium 和 Python

我一直在尝试从 https://www.tradingview.com/markets/stocks-turkey/market-movers- 中提取股票代码(股票的简称)、股票名称、价格、板块和市值列全股票/

回答 1 投票 0

如何在Playwright中查看Toast消息?

我是自动化工具的新手,没有编码技能,所以请尽可能清楚地指导我。 我正在使用 Playwright (Typescript) 对一个基本网站执行自动化测试,并且我有

回答 1 投票 0

如何 xpath 到一个值,无论它是否存在于列表中

我正在尝试使用单个 xpath 行访问 Thing1 和 Thing2 的值。下面的 xpath 是完整 xpath 的结束片段。在此之前的部分在这种情况下并不重要,所以我没有......

回答 1 投票 0

Selenium/Python/Xpath 并在反应文本注释之间获取文本

我有以下 HTML 片段,并发现了如何在 Chrome 中使用以下 Xpath 获取文本(日期和时间)。然而,对于 Selenium,使用 find_element_by_xpath 不起作用,因为......

回答 1 投票 0

发生异常:StaleElementReferenceException 消息:陈旧元素引用:未找到陈旧元素

我想从网站检索该公司。如果没有while循环,代码可以正常运行。但是使用 while 循环,它给了我这个错误:发生异常:StaleElementReferenceException

回答 1 投票 0

如何使用 XSLT 3 中的 xpath() 将元素推送到 XML 中?

我有很大的 XML 文件,需要向其中注入处理指令。处理指令的位置被列为 xpath 位置。我创建了一个小型版本的 XML 文件...

回答 1 投票 0

Selenium 和 XPath - 通过包含文本来定位链接

我正在尝试使用 XPath 来查找包含一段文本的元素,但我无法让它工作...... WebElement searchItemByText = driver.findElement(By.xpath("//*[@id='popover-search']/div/d...

回答 5 投票 0

用c#更新xml的特定值

我一直在使用 c# 中的 xml 更新和插入,但无法实现更新特定值。下面是我的xml数据:

回答 0 投票 0

如何在python中动态查找元素的XPATH?

我正在使用 selenium python 开发一个项目,我可以用它来击败在线游戏(这只是为了好玩而不是为了钱)。我正在寻找一个通过 CSS 类名激活的正方形,然后我想要

回答 1 投票 0

如何在XPath中使用like?

我有一个使用过滤器进行搜索的页面。例如我有这个代码, xmlTempResultSearch = xmlResidentListDisplay.selectNodes("//PeopleList/Row[@LastName != '"+txtSearch.value+"']");

回答 3 投票 0

需要 XPATH 来识别 DIV 中的元素并单击它们的复选框

我需要根据给定的条件单击元素。 这就是我的源的样子: 我需要根据给定的条件单击元素。 这就是我的来源的样子: <div class="oxd-table-card" data-v-f2168256="" style=""> <div class="oxd-table-row oxd-table-row--with-border" role="row" data-v-0d5ef602="" data-v-f2168256="" style=""> <div class="oxd-table-cell oxd-padding-cell" role="cell" style=""> <div class="oxd-table-card-cell-checkbox"> <div class="oxd-checkbox-wrapper" data-v-6179b72a="" style=""> <label class="" data-v-6179b72a=""> <!----> <input type="checkbox" value="0" data-v-6179b72a=""/> <span class="oxd-checkbox-input oxd-checkbox-input--active --label-right oxd-checkbox-input" data-v-6179b72a=""> <i class="oxd-icon bi-check oxd-checkbox-input-icon" data-v-bddebfba="" data-v-6179b72a=""/> </span> </label> </div> </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 0%;"> <div data-v-6c07a142="">25-07-2022 (09:00 - 13:00) Half Day </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 0%;"> <div data-v-6c07a142="">Anthony Nolan </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 0%;"> <div data-v-6c07a142="">CAN - Personal </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 0%;"> <div data-v-6c07a142="">12.50 </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 0%;"> <div data-v-6c07a142="">0.50 </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 0%;"> <div data-v-6c07a142="">Pending Approval (0.50) </div> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 5%;"> <div data-v-6c07a142=""/> </div> <div class="oxd-table-cell oxd-padding-cell" role="cell" style="flex: 1 1 20%;"> <div class="oxd-table-cell-actions" data-v-c423d1fa=""> <button type="button" class="oxd-button oxd-button--medium oxd-button--label-success oxd-table-cell-action-space" data-v-10d463b7="" data-v-c423d1fa=""> <!----> Approve <!----> </button> <button type="button" class="oxd-button oxd-button--medium oxd-button--label-danger oxd-table-cell-action-space" data-v-10d463b7="" data-v-c423d1fa=""> <!----> Reject <!----> </button> <li class="oxd-table-dropdown oxd-table-cell-action-space" disabled="false" data-v-429cfcf3="" data-v-1d22ad12="" data-v-c423d1fa="" style="margin-left: auto;"> <button class="oxd-icon-button" type="button" data-v-f5c763eb="" data-v-1d22ad12=""> <i class="oxd-icon bi-three-dots-vertical" data-v-bddebfba="" data-v-f5c763eb=""> </i> </button> <!----> </li> </div> </div> </div> </div> 这是我迄今为止尝试过的方法,但不起作用。它选择复选框,但不违反下面给出的所有标准: 1- DIV,其中包含请求者姓名 Linda Jane Anderson 2- DIV,其中包含休假类型 CAN - 个人 3- DIV,其中包含待批准的休假状态 这就是我的 XPATH 的样子: //div[contains(text(), "Linda Jane Anderson")] /following::div[contains(text(), "CAN - Personal")] /following::div[contains(text(),"Pending")] /../preceding-sibling::div//input[@type="checkbox"] 你能帮我写一个 XPATH 吗?非常感谢! 假设您的示例中的 Linda Jane Anderson 应该是 Anthony Nolan,您可以使用此 XPath: //div[@role='row'] [div[@role='cell']/div[contains(text(),'Anthony Nolan')]] [div[@role='cell']/div[contains(text(),'CAN - Personal')]] [div[@role='cell']/div[contains(text(),'Pending')]] /div[@role='cell']//input[@type='checkbox']

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.