Nikhil Thota
Nikhil Thota

Reputation: 11

How to find the data_automation_id for creating new workbook in Microsoft sheets online?

I am trying to use Selenium Manager with NuGet packages to simulate real time functional scenarios like Online MS Sheets, and other workloads. I am able to login into the online excel at https://www.microsoft365.com/launch/excel?auth=2.

But I can see that my code might not be using the correct data_automation_id to create a new excel workbook. How do I know the data_automation_id's I would require for creating a workbook, writing some calculations in cells, and then saving it.

I want all of this to be as a real time UI simulation using Selenium

 LogMessage("Attempting to create new workbook...", LogLevel.Info);
 try
 {
     Thread.Sleep(5000);  // Wait for page load

     // Try multiple selectors for the new workbook button
     try
     {
         WaitAndClick(driver, By.XPath("//div[contains(@title, 'New blank workbook')]"), TimeSpan.FromSeconds(20));
     }
     catch
     {
         try
         {
             WaitAndClick(driver, By.XPath("//button[contains(text(), 'New blank workbook')]"), TimeSpan.FromSeconds(20));
         }
         catch
         {
             WaitAndClick(driver, By.CssSelector("[data-automation-id='new-blank-workbook']"), TimeSpan.FromSeconds(20));
         }
     }
     LogMessage("New workbook button clicked successfully", LogLevel.Info);
 }
 catch (Exception ex)
 {
     LogMessage("Failed to create new workbook", LogLevel.Error, ex);
     throw;
 }

Upvotes: 1

Views: 17

Answers (0)

Related Questions