문제

How do I select an email in outlook to assert the contents.

I am currently tasked with testing the live.com mail web page. Live.com WebPage

The problem I am running into is when I go to click the line item for the email I receive an error:

Permission denied to access property '__qosId'

and I cannot for the life of me figure out what is wrong. Code provided below.

    // 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"));

When I get to this step I have tried a few different options already but can't seem to find the right one. I also have written the same test in python but won't bore anyone with the similar code.

    // Opens the first email in the row
    driver.findElement(By.partialLinkText("foo foo")).click();

Error for python looks like this:

WebDriverException: Message: u"Permission denied to access property '__qosId'" ; Stacktrace:

도움이 되었습니까?

해결책

When trying to find a solution for this question, I got the same issue. I believe this is a bug in Selenium.

To achieve what you looking to do, I tried with the JavaScriptExecutor and it worked.

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();");

What do I here, using JavaScript I get all the emails identified by the class "t_estc" and I click the first element of that array.

This will click the first email in your inbox. If you want to parse all the list, do some logic.

다른 팁

You can use below code snippets for your purpose:

Code Snippet 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();

Code Snippet 2:

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top