简体   繁体   English

使用 Playwright 和 C# 访问 Stripe Payment 的输入字段

[英]Access Input field of Stripe Payment using Playwright and C#

I m trying to access the id of the field of card number in stripe so i can input card number using c# and playwright.我正在尝试访问条带中卡号字段的 ID,以便我可以使用 c# 和 playwright 输入卡号。 i have a screenshot of the DOM and I tried the below code but in vain.我有 DOM 的屏幕截图,我尝试了下面的代码但没有成功。 could you please advise on how to access the card number ID?你能告诉我如何访问卡号ID吗?

 var CardNumberLocator = Page.Locator("id=Field-numberInput");
 await CardNumberLocator.FillAsync("1234123412341234");

DOM of the stripe条带的 DOM

This can be caused by multiple reasons;这可能是由多种原因引起的;

If it's embedded.如果嵌入的话。 You need to apply your logic to the Content Frame .您需要将逻辑应用于Content Frame

If it's invisible.如果看不见。 (maybe the focus is triggered through a div click and it's hidden with CSS even if it exists on the HTML), this might be the reason why it's not working because WaitForSelector/Locator waits for the element to be visible. (也许焦点是通过 div 单击触发的,即使它存在于 HTML 中,它也被 CSS 隐藏了),这可能是它不起作用的原因,因为 WaitForSelector/Locator 等待元素可见。 You can try using the page.$ selector, which will return the element whether or not it's invisible.您可以尝试使用page.$选择器,无论它是否不可见,它都会返回元素。

You can also trigger a page.click(div) on the overlayed element [the div in this case], then use page.keyboard.type(text) .您还可以在叠加元素 [本例中为 div] 上触发page.click(div) ,然后使用page.keyboard.type(text) The simulated click will make the page focus on the input.模拟点击会让页面聚焦在输入上。 And the keyboard.type will be typing into the input. keyboard.type将在输入中输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C#中使用Stripe API取消订阅Stripe付款计划 - How to unsubscribe from stripe payment plan using Stripe API in c# 剧作家 C# - 等待输入文本为空 - Playwright C# - wait for input text to be empty 在 C# .net 中访问剧作家中的兄弟元素 - Access to Sibling element in Playwright in C# .net 如何使用 Stripe 支付网关在 C# (dot.net web api) 的服务器端实现 Google Pay? - How to implement Google Pay in Server Side in C# (dot net web api) using Stripe Payment Gateway? 在 C# 中使用 MS Access 查找字段 - Using an MS Access Lookup field in C# Microsoft.Playwright.PlaywrightException:连接月球时无法使用 Playwright C# 验证第一个证书 - Microsoft.Playwright.PlaywrightException : unable to verify the first certificate Using Playwright C# While connecting Moon 无法使用 C# 语言在编剧自动化中下载文件 - Unable to download file in playwright Automation using C# language 使用C#验证Paypal付款 - Verify paypal payment using C# 具有资产Unistripe Unity的支付条在开发版本中起作用,但在生产版本中没有起作用C#Unity - Payment Stripe With Asset Unistripe Unity Worked In Development Build But Not In Production Build C# Unity 验证C#中的输入字段 - Validate input field in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM