Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在outlook中选择电子邮件以声明内容_Java_Python_Email_Selenium_Outlook - Fatal编程技术网

Java 如何在outlook中选择电子邮件以声明内容

Java 如何在outlook中选择电子邮件以声明内容,java,python,email,selenium,outlook,Java,Python,Email,Selenium,Outlook,如何在outlook中选择电子邮件以声明内容。 我目前的任务是测试live.com邮件网页 我遇到的问题是,当我点击收到错误的电子邮件的行项目时: 访问属性“”的权限被拒绝 而我一辈子都无法找出问题所在。代码如下所示 // Create a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); // Create a new instance of the Selenium

如何在outlook中选择电子邮件以声明内容。

我目前的任务是测试live.com邮件网页

我遇到的问题是,当我点击收到错误的电子邮件的行项目时:

访问属性“”的权限被拒绝

而我一辈子都无法找出问题所在。代码如下所示

    // Create a new instance of the Firefox driver
    WebDriver driver = new FirefoxDriver();

    // Create a new instance of the Selenium backed webdriver
    Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);

    // And now use this to visit Live.com
    driver.get("https://mail.live.com/");

    // Find the text input element by its name
    WebElement emailField = driver.findElement(By.id("i0116"));
    // Enter your email
    emailField.sendKeys(email);

    // Repeat process for Password field
    WebElement passField = driver.findElement(By.id("i0118"));
    passField.sendKeys(password);

    // Sign In button
    WebElement signInBtn = driver.findElement(By.name("SI"));
    signInBtn.click();

    // Click the compatibility link
    driver.findElement(By.linkText("continue to your inbox")).click();

    // Assert some things
    assertTrue(selenium.isTextPresent("Inbox"));
当我走到这一步时,我已经尝试了一些不同的选择,但似乎找不到合适的。我也用python编写了相同的测试,但不会让任何人对类似的代码感到厌烦

    // Opens the first email in the row
    driver.findElement(By.partialLinkText("foo foo")).click();
python的错误如下所示:

WebDriverException:消息:u“访问属性'\u qosId'的权限被拒绝”;堆栈跟踪:


当我试图找到这个问题的解决方案时,我遇到了同样的问题。我相信这是硒的一个缺陷

为了实现您想要做的事情,我尝试了JavaScriptExecutor,它成功了

WebDriver driver = new FirefoxDriver();
driver.get("https://mail.live.com/");

driver.findElement(By.name("login")).sendKeys("email@live.com");
driver.findElement(By.name("passwd")).sendKeys("password");
driver.findElement(By.name("SI")).click();      

Thread.sleep(2000); // change that as you wish. or use global wait.

((JavascriptExecutor) driver).executeScript("document.getElementsByClassName('t_estc')[0].click();");
我在这里做什么,使用JavaScript我得到了类“t_estc”标识的所有电子邮件,然后单击该数组的第一个元素


这将单击收件箱中的第一封电子邮件。如果要解析所有列表,请执行一些逻辑操作。

您可以使用以下代码片段:

代码片段1:

driver.get("https://mail.live.com/");

driver.findElement(By.name("login")).sendKeys("email@live.com");
driver.findElement(By.name("passwd")).sendKeys("password");
driver.findElement(By.name("SI")).click();      

//insert code to wait for an element available on the landing page

List<WebElement> email = driver.findElements(By.xpath("//span[@class='Sb']"));
email.get(0).click();

你能分享一段HTML吗?我只是没有账户。但查看WebDriver的可能位置会很有趣。运行顶部代码段并在stacktrace下接收到:org.openqa.selenium.WebDriverException:访问属性“\uu qosId”的权限被拒绝命令持续时间或超时:38毫秒Bottom代码段失败,此行的stacktrace相同:WebElement电子邮件=findElements(By.xpath(“//span[@class='Sb'][1]”);
driver.get("https://mail.live.com/");

driver.findElement(By.name("login")).sendKeys("email@live.com");
driver.findElement(By.name("passwd")).sendKeys("password");
driver.findElement(By.name("SI")).click();      

//insert code to wait for an element available on the landing page

WebElement email = driver.findElements(By.xpath("//span[@class='Sb'][1]"));
email.click();