Selenium can't locate iframe

后端 未结 5 1444
栀梦
栀梦 2021-01-16 00:24

Selenium fails to locate the iframe by ID and Name.

This is for an automated checkout test on Shopify. The specific issue lies within the p

5条回答
  •  情话喂你
    2021-01-16 00:47

    It is possible to use XPath for this I believe. You will need to find the IFrame IWebElement with XPath, and then pass the IWebElement into the SwitchTo().Frame()

    var ele = driver.FindElement(By.XPath("//iframe[contains(id, 'card-fields-number')]"));
    
    driver.switchTo().frame(ele);
    

提交回复
热议问题