I have some tests. Sometimes, if an item cannot be found, it simply presses the top left of the screen. This does not always happen, but it does. I do not know why this is happening. In my setUp method, I say to click the Maximize element, however, if it cannot find this element, I put it in catch and ignore it. For some reason, when he cannot find the item, he simply clicks on the upper left corner of the screen on which there is an application session.
Does anyone have any idea why this is happening, or is it just how selenium sometimes reacts
My code is as follows
private string wordId = OfficeVersion.Word(); private string excelId = OfficeVersion.Excel(); private string powerPointId = OfficeVersion.PowerPoint(); private const string AppDriverUrl = "http://127.0.0.1:4723"; public static WindowsDriver<WindowsElement> excelSession; public static WebDriverWait webDriverWait; xl.Workbook WB; public static bool skipTearDown = false; WindowsElement create; WindowsElement blankWorkBook; public static DesiredCapabilities appCapabilities = new DesiredCapabilities(); [TestInitialize] appCapabilities.SetCapability("app", excelId); var initialSession = new WindowsDriver<WindowsElement>(new Uri(AppDriverUrl), appCapabilities); var capabilities = new DesiredCapabilities(); capabilities.SetCapability("app", "Root"); excelSession = new WindowsDriver<WindowsElement>(new Uri(AppDriverUrl), capabilities); webDriverWait = new WebDriverWait(excelSession, TimeSpan.FromSeconds(10)); CommonMethods.keyCheck(excelSession); webDriverWait = new WebDriverWait(excelSession, TimeSpan.FromSeconds(10)); CommonMethods.IsElementDisplayed(excelSession, new StackTrace(true).GetFrame(0).GetFileLineNumber(), new StackTrace(true).GetFrame(0).GetMethod(), "CreateErrorIcon", "Create error when launching Excel"); try {
This is an element that I have a problem with ignoring if it does not exist
webDriverWait.Until(ExpectedConditions.ElementToBeClickable(excelSession.FindElementByName("Maximize"))).Click(); } catch (Exception) {
source share