[Test, Order(1)] //Identifying method as TestCase and specifying the execution order public void Verify_AddProductToCart(string browserName) { NavigateToHomePage(browserName); //DataTable rCnt = Excel_Library.GetNumberOfRows(@"C:\Users\Karthee\Desktop\Login_Credentials.xlsx", "Sheet1"); // DataTable rCnt = Excel_Library.GetNumberOfRows(@"C:\Users\sriramdasbalaji\Source\Repos\Selenium\test\PartsUnlimited.SeleniumTests\Excel_Files\Login_Credentials.xlsx", "Sheet1"); string email = "*****@*****.**"; //Convert.ToString(rCnt.Rows[0]["Email"]); string password = "******"; //Convert.ToString(rCnt.Rows[0]["Password"]); //------ Login to application --------------- //Click on Login icon PropertiesCollection.LoginObject.clickLoginBtn(); Base_Class.Wait(); //Implicit wait of 3000ms //Type in Email ID and Password PropertiesCollection.LoginObject.Type_Email(email); PropertiesCollection.LoginObject.Type_Password(password); //Click on Login button PropertiesCollection.LoginObject.clickLoginOnPage(); Base_Class.Wait(); //------ Adding product/s to cart page --------------- //Scroll till element "Synthetic Engine oil" using Javascript IJavaScriptExecutor js = PropertiesCollection.driver as IJavaScriptExecutor; js.ExecuteScript("window.scroll(0, 1500);"); Base_Class.Wait(); //Identifying the product and add to cart if (PropertiesCollection.CartPageObjects.AlloyRim.Displayed) { PropertiesCollection.CartPageObjects.Click_AlloyRim(); //Click on item Base_Class.Wait(); PropertiesCollection.CartPageObjects.Click_AddtoCart(); //Click on Add to cart button Base_Class.Wait(); //cartValue = PropertiesCollection.CartPageObjects.cartCount.Text; //Storing the cart-count in var "Cart_Value" Console.WriteLine("Items added to cart page. Following are the product details:\n"); Base_Class.Wait(); //Identifying the number of product/s in cart page IList <IWebElement> summary = PropertiesCollection.driver.FindElements(By.XPath("//div[@class='row']/div[5]/div[1]/strong/a")); //Displaying the cart summary details foreach (var item in summary) { Console.WriteLine(item.Text + "\n"); } } else { Console.WriteLine("Search item could not be found.\n"); } }
public void navigatehomepage(string browserName) { NavigateToHomePage(browserName); //string email = "*****@*****.**";//Convert.ToString(rCnt.Rows[0]["Email"]); //string password = "******";//Convert.ToString(rCnt.Rows[0]["Password"]); //wait Base_Class.Wait(); }
public Base(string _name, Base_Class _type, bool _built) : base(_type, 1) { this.type = _type; this.name = _name; this.started_at = G.pl.raw_min; this.location_id = string.Empty; //BaseES suspicion is currently unused this.suspicion = new SerializableDictionary <string, int> (); this.raw_cpu = 0; this.cpu = 0; //Reactor, network, security. this.extra_items = new List <Item> () { null, null, null }; // [None] * 3 this.cpus = null; if (!string.IsNullOrEmpty((this.type as Base_Class).force_cpu)) { // 1% chance for a Stolen Computer Time base to have a Gaming PC // instead. If the base is pre-built, ignore this. if (this.type.id == "Stolen Computer Time" && G.roll_percent(100) && !_built) { this.cpus = new Item(G.items["Gaming PC"], this, (this.type as Base_Class).size, true); } else { this.cpus = new Item(G.items[(this.type as Base_Class).force_cpu], this, (this.type as Base_Class).size, true); } // this.cpus.finish (); ..(we cannot haz Base as a member in Item because of circular ref in XMLSerializer, we haz this.id instead and iterate over current bases, but this one is not in G.all_bases() since its being created now..)] // so instead we have _built = true for Item ctor above } if (_built) { this.finish(); } this.power_state = "active"; this.grace_over = false; this.maintenance = new long[(this.type as Base_Class).maintenance.Length]; (this.type as Base_Class).maintenance.CopyTo(this.maintenance, 0); }
//// Generates a name for a base, given a particular location. string generate_base_name(Location location, Base_Class base_type) { string name = string.Empty; string city = string.Empty; // First, decide whether we're going to try significant values or just // choose one randomly. if (Random.value < 0.3) // 30% chance. { int attempts = 0; bool done = false; bool duplicate = false; while (!done && attempts < 5) { city = location.cities.Count > 0 ? location.cities[Random.Range(0, location.cities.Count)] : string.Empty; name = city + " " + base_type.flavor[Random.Range(0, base_type.flavor.Count)] + " " + this.significant_numbers[Random.Range(0, this.significant_numbers.Count)].ToString(); duplicate = false; foreach (Base _base in location.bases) { if (_base.name == name) { duplicate = true; break; } } if (duplicate) { attempts += 1; } else { done = true; } } if (done) { return(name); } } // This is both the else case and the general case. city = location.cities.Count > 0 ? location.cities[Random.Range(0, location.cities.Count)] : string.Empty; name = city + " " + base_type.flavor[Random.Range(0, base_type.flavor.Count)] + " " + Random.Range(0, 32767).ToString(); return(name); }
public void Verify_Login(string browserName) { NavigateToHomePage(browserName); //DataTable rCnt = Excel_Library.GetNumberOfRows(HostingEnvironment.MapPath(@".\Login_Credentials.xlsx", "Sheet1")); string email = "*****@*****.**"; //Convert.ToString(rCnt.Rows[0]["Email"]); string password = "******"; //Convert.ToString(rCnt.Rows[0]["Password"]); //wait Base_Class.Wait(); //Click on Login button PropertiesCollection.LoginObject.clickLoginBtn(); //wait Base_Class.Wait(); //Enter Email ID from excel PropertiesCollection.LoginObject.Type_Email(email); //Enter Password from excel PropertiesCollection.LoginObject.Type_Password(password); Base_Class.Wait(); //Click on Login button PropertiesCollection.LoginObject.clickLoginOnPage(); //Displays when there is no validation message Console.WriteLine(" User logged into 'PartsUnlimited' application succesfully. "); //wait //Base_Class.Wait(); //Click on Profile field //PropertiesCollection.LoginObject.clickProfile(); //wait //Base_Class.Wait(); //Click on Manage User link //PropertiesCollection.LoginObject.clickManageUser(); //wait //Base_Class.Wait(); //Get the logged in user email id //String Username = PropertiesCollection.driver.FindElement(By.XPath("//dd[contains(text(),'" + UserName + "')]")).Text; //Console.WriteLine("Logged In Email ID is : " + Username); }
public void Verify_Logout(string browserName) { NavigateToHomePage(browserName); // DataTable rCnt = Excel_Library.GetNumberOfRows(@"C:\Users\sriramdasbalaji\Source\Repos\Selenium\test\PartsUnlimited.SeleniumTests\Excel_Files\Login_Credentials.xlsx", "Sheet1"); string email = "*****@*****.**"; //Convert.ToString(rCnt.Rows[0]["Email"]); string password = "******"; //Convert.ToString(rCnt.Rows[0]["Password"]); //wait Base_Class.Wait(); //Click on Login button PropertiesCollection.LoginObject.clickLoginBtn(); //wait Base_Class.Wait(); //Enter Email ID from excel PropertiesCollection.LoginObject.Type_Email(email); //Enter Password from excel PropertiesCollection.LoginObject.Type_Password(password); //Click on Login button PropertiesCollection.LoginObject.clickLoginOnPage(); //wait Base_Class.Wait(); //Click on Profile field PropertiesCollection.LoginObject.clickProfile(); //wait Base_Class.Wait(); //Click on Logout button PropertiesCollection.LoginObject.clickLogOffBtn(); //Displays when there is no validation message Console.WriteLine(" User logged out from 'PartsUnlimited' application succesfully. "); }
[TearDown] // Identifies a method to be executed each time after a TestMethod/Test has executed public void CloseBrowser() { Base_Class.CleanUp(); }
public void CloseBrowser() { //Close the browser Base_Class.CleanUp(); }
//// Generates a name for a base, given a particular location. string generate_base_name(Location location, Base_Class base_type) { string name = string.Empty; string city = string.Empty; // First, decide whether we're going to try significant values or just // choose one randomly. if (Random.value < 0.3 ) // 30% chance. { int attempts = 0; bool done = false; bool duplicate = false; while (!done && attempts < 5) { city = location.cities.Count > 0 ? location.cities[Random.Range(0, location.cities.Count)] : string.Empty; name = city + " " + base_type.flavor[Random.Range(0,base_type.flavor.Count)] + " " + this.significant_numbers[Random.Range(0,this.significant_numbers.Count)].ToString(); duplicate = false; foreach( Base _base in location.bases ) { if ( _base.name == name ) { duplicate = true; break; } } if (duplicate) attempts += 1; else done = true; } if (done) return name; } // This is both the else case and the general case. city = location.cities.Count > 0 ? location.cities[Random.Range(0, location.cities.Count)] : string.Empty; name = city + " " + base_type.flavor[Random.Range(0,base_type.flavor.Count)] + " " + Random.Range(0, 32767).ToString(); return name; }
void NewBaseGUI () { GUI.enabled = this.newBaseNameGUI == null; GUI.Box ( GUI_bindings.MESSAGE_BOX_RECT, ""); GUI.Box ( GUI_bindings.MESSAGE_BOX_RECT, ""); GUI.Box ( GUI_bindings.MESSAGE_BOX_RECT, ""); GUILayout.BeginArea ( GUI_bindings.MESSAGE_BOX_RECT ); GUILayout.BeginHorizontal (); scrollPositionBaseTypes = GUILayout.BeginScrollView (scrollPositionBaseTypes); this.selectedNewBaseTypeIdx = GUILayout.SelectionGrid (this.selectedNewBaseTypeIdx, base_types_names, 1, GUI_bindings.Instance.SelectionGrid() ); GUILayout.EndScrollView (); if (this.selectedNewBaseTypeIdx != this.selectedNewBaseTypeIdxPrev) { this.selectedNewBaseTypeIdxPrev = this.selectedNewBaseTypeIdx; this.base_type = G.base_type.Values.First( f => f.name == this.base_types_names[this.selectedNewBaseTypeIdx] ); this.base_type_info = this.base_type.get_info (this.location); } this.scrollPositionLabel = GUILayout.BeginScrollView (this.scrollPositionLabel, GUILayout.MaxWidth( (int)(Screen.width / 2 ) ) ); GUILayout.Label (this.base_type_info, GUI_bindings.Instance.LabelAlt(true,null, false), GUILayout.MaxWidth( (int)(Screen.width / 2 ) ) ); GUILayout.EndScrollView (); GUILayout.EndHorizontal (); GUILayout.BeginHorizontal (); if (GUILayout.Button ("OK")) { if (this.selectedNewBaseTypeIdx >= 0) { this.new_base_name = this.generate_base_name (this.location, this.base_type); this.newBaseNameGUI = this.NewBaseName; G.play_sound(); } } if (GUILayout.Button ("Back")) { this.newBaseGUI = null; G.play_sound(); } GUILayout.EndHorizontal (); GUILayout.EndArea(); if (this.newBaseNameGUI != null) this.newBaseNameGUI (); }
public Base (string _name, Base_Class _type, bool _built) : base(_type, 1) { this.type = _type; this.name = _name; this.started_at = G.pl.raw_min; this.location_id = string.Empty; //BaseES suspicion is currently unused this.suspicion = new SerializableDictionary<string, int> (); this.raw_cpu = 0; this.cpu = 0; //Reactor, network, security. this.extra_items = new List<Item> () { null, null, null } ; // [None] * 3 this.cpus = null; if (!string.IsNullOrEmpty ((this.type as Base_Class).force_cpu)) { // 1% chance for a Stolen Computer Time base to have a Gaming PC // instead. If the base is pre-built, ignore this. if (this.type.id == "Stolen Computer Time" && G.roll_percent (100) && !_built) this.cpus = new Item (G.items["Gaming PC"], this, (this.type as Base_Class).size, true); else this.cpus = new Item (G.items[(this.type as Base_Class).force_cpu], this, (this.type as Base_Class).size, true); // this.cpus.finish (); ..(we cannot haz Base as a member in Item because of circular ref in XMLSerializer, we haz this.id instead and iterate over current bases, but this one is not in G.all_bases() since its being created now..)] // so instead we have _built = true for Item ctor above } if (_built) this.finish (); this.power_state = "active"; this.grace_over = false; this.maintenance = new long[(this.type as Base_Class).maintenance.Length]; (this.type as Base_Class).maintenance.CopyTo(this.maintenance,0); }
void NewBaseGUI() { GUI.enabled = this.newBaseNameGUI == null; GUI.Box(GUI_bindings.MESSAGE_BOX_RECT, ""); GUI.Box(GUI_bindings.MESSAGE_BOX_RECT, ""); GUI.Box(GUI_bindings.MESSAGE_BOX_RECT, ""); GUILayout.BeginArea(GUI_bindings.MESSAGE_BOX_RECT); GUILayout.BeginHorizontal(); scrollPositionBaseTypes = GUILayout.BeginScrollView(scrollPositionBaseTypes); this.selectedNewBaseTypeIdx = GUILayout.SelectionGrid(this.selectedNewBaseTypeIdx, base_types_names, 1, GUI_bindings.Instance.SelectionGrid()); GUILayout.EndScrollView(); if (this.selectedNewBaseTypeIdx != this.selectedNewBaseTypeIdxPrev) { this.selectedNewBaseTypeIdxPrev = this.selectedNewBaseTypeIdx; this.base_type = G.base_type.Values.First(f => f.name == this.base_types_names[this.selectedNewBaseTypeIdx]); this.base_type_info = this.base_type.get_info(this.location); } this.scrollPositionLabel = GUILayout.BeginScrollView(this.scrollPositionLabel, GUILayout.MaxWidth((int)(Screen.width / 2))); GUILayout.Label(this.base_type_info, GUI_bindings.Instance.LabelAlt(true, null, false), GUILayout.MaxWidth((int)(Screen.width / 2))); GUILayout.EndScrollView(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("OK")) { if (this.selectedNewBaseTypeIdx >= 0) { this.new_base_name = this.generate_base_name(this.location, this.base_type); this.newBaseNameGUI = this.NewBaseName; G.play_sound(); } } if (GUILayout.Button("Back")) { this.newBaseGUI = null; G.play_sound(); } GUILayout.EndHorizontal(); GUILayout.EndArea(); if (this.newBaseNameGUI != null) { this.newBaseNameGUI(); } }