using OpenQA.Selenium.Support.UI;
using System.Threading.Tasks;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
namespace ReportAutomation
static void Main(string[] args)
IWebDriver driver = new ChromeDriver(@"C:\winapps");
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("https://webportal.gfk.com/BG/A/Account#/Login");
Console.WriteLine("Enter a Username");
string username = Console.ReadLine();
driver.FindElement(By.XPath("//*[@id='Username']/div/input")).SendKeys(username);
Console.WriteLine("Enter a Password");
key = Console.ReadKey(true);
if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
if (key.Key == ConsoleKey.Backspace && password.Length > 0)
password = password.Substring(0, (password.Length - 1));
while (key.Key != ConsoleKey.Enter);
driver.FindElement(By.XPath("//*[@id='Password']/div/input")).SendKeys(password);
driver.FindElement(By.XPath("//*[@id='Login-button']/span")).Click();
dayCreate(driver, username);
for (int i = 0; i < 5; i++)
driver.FindElement(By.XPath("//*[@id='Lines-list-linked']/div/div[1]/div[2]/div[2]/div/span[1]/button/i")).Click();
dayCreate(driver, username);
static void consumerCenter(IWebDriver driver, string username)
driver.FindElement(By.XPath("//*[@id='LinesForm']/div/div[3]/form/div[2]/div/div[1]/div[4]/div")).Click();
if (username == "gfk\\yordan.georgiev")
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys("SE c");
else if (username == "gfk\\bozhidar.milchov")
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys("SE c");
else if (username == "gfk\\oleg.sotirov")
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys("SE c");
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys("SE d");
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys(Keys.Enter);
static void dayCreate(IWebDriver driver, string username)
driver.FindElement(By.XPath("//*[@id='CreateVP-button']")).Click();
var dayDisplayFetch = driver.FindElement(By.XPath("//*[@id='CreateVP-button']/span"));
string dayDisplay = (dayDisplayFetch.Text).Replace("Create ", "");
Console.WriteLine("Working hours for {0}: ",dayDisplay);
string workingHours = Console.ReadLine();
driver.FindElement(By.XPath("//*[@id='s2id_autogen29']/a/div")).Click();
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys("project");
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys(Keys.Enter);
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div")).Click();
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys(workingHours + Keys.Enter);
consumerCenter(driver, username);
driver.FindElement(By.XPath("//*[@id='CreateVP-button']")).Click();
Console.WriteLine("Non-working hours for {0}: ", dayDisplay);
string slackHours = Console.ReadLine();
driver.FindElement(By.XPath("//*[@id='s2id_autogen29']/a/div")).Click();
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys("general");
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys(Keys.Enter);
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div")).Click();
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys(slackHours + Keys.Enter);
consumerCenter(driver, username);
driver.FindElement(By.XPath("//*[@id='CreateVP-button']")).Click();
Console.WriteLine("Meeting hours for {0}: ",dayDisplay);
string meetingHours = Console.ReadLine();
driver.FindElement(By.XPath("//*[@id='s2id_autogen29']/a/div")).Click();
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys("302");
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys(Keys.ArrowDown);
driver.FindElement(By.XPath("//*[@id='select2-drop']/div/input")).SendKeys(Keys.Enter);
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div")).Click();
driver.FindElement(By.XPath("//*[@id='TimeRecordingEntries_Hours']/div/input")).SendKeys(meetingHours + Keys.Enter);
consumerCenter(driver, username);