【问题标题】:Input not accepted by fields字段不接受输入
【发布时间】:2021-09-05 02:47:20
【问题描述】:

我有一个网站,我想在其中运行购物车功能的完整过程。一切顺利,直到我单击付款方式并选择借记卡和。将数据放入字段中时,它不接受。如何将数据放入字段中。这是要测试的网站的链接:https://vapesuite.allomate.solutions/#/。下面是在字段中输入数据的代码。

    wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[contains(@name, 'zoid__paypal_buttons')]")));
System.out.println("We have selected Credit card method");
Thread.sleep(5000);

WebElement debitCreditCardButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//span[text()='Debit or Credit Card']")));
debitCreditCardButton.click();
Thread.sleep(5000);
        
driver.switchTo().defaultContent();
js.executeScript("window.scrollBy(0,800)");
//Here is the problem, the below path not working   
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id="credit-card-number"]"))).sendKeys("4111111111111111");

【问题讨论】:

标签: java eclipse selenium selenium-webdriver


【解决方案1】:

有嵌套的 iframe:

卡号好像在里面

div[id^='zoid-paypal-card-fields-uid_']

iframe。

使用此代码:

debitCreditCardButton.click();
Thread.sleep(5000);
driver.switchTo().defaultContent();
js.executeScript("window.scrollBy(0,800)");
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("div[id^='zoid-paypal-card-fields-uid_']")));
// and then send keys to card number input field. 

wait.until(ExpectedConditions.elementToBeClickable(By.id("credit-card-number"))).sendKeys("4111111111111111");

【讨论】:

  • 我尝试了您的代码,但它显示错误:prnt.sc/1672u50
  • 我的错!而是使用这个 css iframe[name^='__zoid__paypal_card_fields__'] 代替 div[id^='zoid-paypal-card-fields-uid_']
  • 我认为iframe[name^='__zoid__paypal_card_fields__'] 又在//iframe[contains(@name, 'zoid__paypal_buttons')] 中,所以没有必要做driver.switchTo().defaultContent(); - 删除它然后尝试
  • @Zaman10 :我无法回复你。该线程不允许我输入任何内容
  • 我已向您发送了聊天邀请。您可以在 StackOverflow 上聊天吗?
猜你喜欢
  • 2017-05-18
  • 1970-01-01
  • 2020-01-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多