public bool Follow() { IWebElement followSucces = null; var followButton = InstaDriver.FindElementByXPath("//*[contains(@type,'button') and text() = 'Follow']"); followButton.Click(); try { followSucces = DriverExtensions.FindElement(InstaDriver, By.XPath("//*[contains(@type,'button') and text() = 'Message']"), 20); LogHelper.Log($"Succesfully followed {_userProfileURL}"); } catch (Exception ex) { LogHelper.Log($"Failed to follow {_userProfileURL} ---- {ex.GetType()}"); } if (followButton != null) { return(true); } else { return(false); } }
public void ThenShouldBeLoggedIn() { home = new HomePage(driver); home.HomeLink.Click(); home.MyAccount.Click(); GetScreesnhot(); Assert.IsTrue(DriverExtensions.FindElement(driver, By.XPath("//h1[text()='My account']"), 10).Displayed); GetScreesnhot(); }
public void PassLoginPopUps() { try { IWebElement saveLoginInfo = DriverExtensions.FindElement(InstaDriver, By.XPath("//*[contains(@class,'sqdOP yWX7d y3zKF ')]"), 20); saveLoginInfo.Click(); IWebElement turnOnNotifications = DriverExtensions.FindElement(InstaDriver, By.XPath("//*[contains(@class,'aOOlW HoLwm ')]"), 20); turnOnNotifications.Click(); } catch (Exception ex) { } }
public Home PerformLogin(string emailOrPhone) { InstagramAccount instaAccount = null; try { instaAccount = SQLiteDatabaseAccess.GetInstagramAccount(emailOrPhone); LoggedAccount = emailOrPhone; } catch (Exception ex) { } if (instaAccount != null) { try { IWebElement cookiesAccept = DriverExtensions.FindElement(InstaDriver, By.XPath("//*[contains(@class,'aOOlW bIiDR ')]"), 20); cookiesAccept.Click(); IWebElement loginEmail = InstaDriver.FindElementByXPath("//*[contains(@aria-label,'Phone number, username, or email')]"); loginEmail.SendKeys(emailOrPhone); IWebElement loginPassword = InstaDriver.FindElementByXPath("//*[contains(@aria-label,'Password')]"); loginPassword.SendKeys(instaAccount.Password); IWebElement loginButton = InstaDriver.FindElementByXPath("//*[contains(@type,'submit')]"); loginButton.Click(); if (CheckIsLoggedIn()) { PassLoginPopUps(); LogHelper.Log("Succesfully logged in"); return(new Home(InstaDriver)); } } catch (Exception ex) { LogHelper.Log($"Some error occured trying to login..., {ex.GetType()}"); } } return(null); }