Firstone

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

using System;

using System.Threading;
using System.Collections;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System.Collections.ObjectModel;
using SeleniumExtras.WaitHelpers;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Edge;
using ExpectedConditions = SeleniumExtras.WaitHelpers.ExpectedConditions;

namespace UnitTestProject3
{

[TestClass]
public class UnitTest1
{
private const string url =
"https://ktestsg890tp2patorg122.crm10.dynamics.com/apps";
private const string userId = "[email protected]";
private const string password = "Sep@2017";

TimeSpan timeOut = TimeSpan.FromSeconds(100);


[TestInitialize]
[TestMethod]
public void TestMethod1()
{
IWebDriver webDriver = new ChromeDriver();
webDriver.Manage().Window.Maximize();
WebDriverWait wait = new WebDriverWait(webDriver, timeOut);
//signin to crm
webDriver.Navigate().GoToUrl(url);

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("i0
116")));
webDriver.FindElement(By.Id("i0116")).SendKeys(userId);

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id
("idSIButton9")));
webDriver.FindElement(By.Id("idSIButton9")).Click();

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("i0
118")));
webDriver.FindElement(By.Id("i0118")).SendKeys(password);

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id
("idSIButton9")));
webDriver.FindElement(By.Id("idSIButton9")).Click();

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible((By.XPath
("//*[@id=\"idSIButton9\"]")))).Click();

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.TitleIs(webDriver.Title));
webDriver.SwitchTo().Frame("AppLandingPage");
webDriver.FindElement(By.Id("app-create-new-app-button")).Click();
}
public Boolean isElementPresent(IWebDriver webDriver, By by)
{
try
{
webDriver.FindElement(by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
}
}

You might also like