I have been tasked with a selenium project where multiple websites have to be tested. The problem is that some times the elements are changed(eg. ID, Xpath, etc). So I wanted to lode the codes from a text file and execute it on the same instance of the application. A sample of how I wish to proceed:
Initialization() 'Initializes the driver
Dim objReader As New System.IO.StreamReader(FILE_NAME)' Reader to read from a partictlar file
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox2.SelectedIndex = i
driver.Navigate.GoToUrl(ListBox1.SelectedIndex)
Do While objReader.Peek() <> -1
execute(objReader.ReadLine())' Run the line of code from the file.
Loop
objReader.Close()
Next
Termination()'Close the driver
Contents of the sample text file :
Dim SearchBox As IWebElement
SearchBox = GetWebElement(driver, By.XPath("/html/body/form/div/section/div/div[1]/div[3]/div[1]/input"), timeOut)
SearchBox.SendKeys(ListBox2.SelectedItem)
ref: Load VB.net code from .txt file and execute it on fly using System.CodeDom.Compiler
May be there is a solution in the above links, a little guidance would be helpful.
Thanks.