Selenium 附加类的运行时异常

Selenium 附加类的运行时异常,selenium,selenium-webdriver,webdriver,selenium-chromedriver,Selenium,Selenium Webdriver,Webdriver,Selenium Chromedriver,对于所附的程序文件,我面临一个附加类的问题。这行代码失败了 CSS: 但我在console中不断遇到这个错误: *** Element info: {Using=xpath, value=//a[contains(@data-dojo-attach-‌​point,'sign_in_butto‌​n')]} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeC

对于所附的程序文件,我面临一个附加类的问题。这行代码失败了

CSS:

但我在console中不断遇到这个错误:

*** Element info: {Using=xpath, value=//a[contains(@data-dojo-attach-‌​point,'sign_in_butto‌​n')]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:476)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at WebFlock.main(WebFlock.java:23)
代码:

请尝试以下代码:

drive.switchTo().frame(drive.findElement(By.cssSelector("#dijit__WidgetsInTemplateMixin_0 > iframe")));

        WebDriverWait wait = new WebDriverWait(drive,15);

        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("a.btn")));

        drive.findElement( By.cssSelector("a.btn")).click();
说明:


该元素出现在一个平面上;因此,为了访问该元素,我们首先需要使用.switchTo.frame方法切换到iframe。

只需使用driver.findElementBy.xpath//a即可[contains@data-dojo附着点,'sign_in_button']。单击;仍然得到相同的错误响应是不清楚的,从你已经张贴;你能更新一下吗?@kushal。更新了错误响应
*** Element info: {Using=xpath, value=//a[contains(@data-dojo-attach-‌​point,'sign_in_butto‌​n')]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:371)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:476)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at WebFlock.main(WebFlock.java:23)
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class WebFlock {

    public static void main(String[] args) throws Exception {
        //open flock.co on chrome
        WebDriver drive;
        String url = "https://flock.co/?";
        System.setProperty("webdriver.chrome.driver", "C:\\Automation\\chromedriver_win32\\chromedriver.exe");
        drive = new ChromeDriver();
        drive.get(url);
        Thread.sleep(5000);

        //find the email text box, enter email and click submit 
        drive.findElement(By.cssSelector("Input[placeholder ='Enter your work email']")).sendKeys("me@farzanshaikh.com");
        drive.findElement(By.cssSelector("button[type='submit']")).click();

        Thread.sleep(8000); //wait for loader to resolve

        drive.findElement( By.cssSelector(".btn.btn--action.btn--block")).click();

    }

}
drive.switchTo().frame(drive.findElement(By.cssSelector("#dijit__WidgetsInTemplateMixin_0 > iframe")));

        WebDriverWait wait = new WebDriverWait(drive,15);

        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("a.btn")));

        drive.findElement( By.cssSelector("a.btn")).click();