I am currently trying to click an element on a webpage using selenium with C#. I need to click a Div element based on a child element that has the text 'Test App'.
Here is the HTML snippet for the object;
<div class="application_items">
<a href="www.google.com" target="_self">
<div class="homePageItems">
<div class="small" style="display: block;">
<div class="AppLabel">Test App</div>
</div>
<div class="big" style="display: none;">
<div class="AppLabel">Test App</div>
<div class="underTitle"></div>
</div>
</div>
</a></div>
And here is my C# code to try access the first appearance of the app name 'Test App';
Element(By.XPath("//div[@class='small']/*[text()[contains(., 'Test App')]]"));
When this runs, I get an error;
OpenQA.Selenium.ElementNotInteractableException: 'Element <div class="AppLabel"> could not be scrolled into view'
I thought the error may be because the program was accessing the second occurence of 'App Test', so I have tried setting the div with the class 'big' visible (display: block;) with the following code, but it doesn't seem to help;
IWebElement elem = Driver.FindElement(By.XPath("//div[@class='small']/div[text()[contains(., 'Test App')]]"));
String js = "arguments[0].style.height='auto'; arguments[0].style.display='block';";
((IJavaScriptExecutor)Driver).ExecuteScript(js, elem);
I apologise if something similar to this has been asked before, I spent a while browsing similar subjects but didn't find what I needed. If anyone could please point me in the right direction, that would be much appreciated.