Why am I getting this error message? It is this line in my code that it is complain about:
website = x1range.Cells[i][1].value2;
I am getting
Error CS0021 Cannot apply indexing with [] to an expression of type 'object'
This is my code:
using System; using System.Threading; using OpenQA.Selenium; using
OpenQA.Selenium.Chrome; using excel =
Microsoft.Office.Interop.Excel;
namespace Create Editions
{
class Program
{
static void Main(string[] args)
{
excel.Application x1app = new excel.Application();
excel.Workbook x1workbook = x1app.Workbooks.Open(@"D:\DATA\CreateEditions.xlsx");
excel._Worksheet x1worksheet = (excel._Worksheet)x1workbook.Sheets[1];
excel.Range x1range = x1worksheet.UsedRange;
string website;
for(int i=1; i<=3; i++)
{
website = x1range.Cells[i][1].value2;
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl(website);
}
}
}
}