I’ve the following HTML code:
<div _ngcontent-fsi-c26="" class="col-xs-12 ng-star-inserted" style="margin-top: 3%;">
<div _ngcontent-fsi-c26="" class=" col-xs-offset-1 col-xs-4">
<button _ngcontent-fsi-c26="" buttontype="secondary" spaui-button-custom="" type="button" class="spaui-button secondary"><!---->
<!---->
<!---->
<!---->CONSULTAR PRODUTO<!----></button>
</div>
<!----><div _ngcontent-fsi-c26="" class="col-xs-offset-2 col-xs-4 ng-star-inserted">
<button _ngcontent-fsi-c26="" buttontype="primary" spaui-button-custom="" type="button" class="spaui-button primary"><!---->
<!---->
<!---->
<!---->CANCELAR PRODUTO<!----></button>
</div>
</div>
What i’ve been trying to achive: Of course i didn’t posted the entire HTML code, too much. However, this button interacts with a radio button on a table. Considering the manual process, i would click on the radio button (to select the option) and then click on the button with the text “CONSULTAR PRODUTO”. Here’s the code i’ve been using to reach the button.
driver.FindElement(By.ClassName("accordion-tab-body")); //After clicking on an accordion it expands a table with all the data i need.
var accordionData = driver.FindElement(By.CssSelector("div > spaui-datatable > table > tbody")); //Navigating to the table to get its elements
var rows = accordionData.FindElements(By.CssSelector("tr")); //Each table row. Ignorind table head, not interesting right now
foreach(var currData in rows)
{
var lines = currData.FindElements(By.CssSelector("td"));
foreach(var currTd in lines)
{
if(currTd.Text == "") //If the text is blank, means the first element - wich is the radio button icon
{
currTd.Click(); //Radio selected
var consultarProdutoBtn = driver.FindElement(By.CssSelector("div > div > div > button")); //The related button was found (i think).
consultarProdutoBtn.Click(); //Where it crashes.
}
}
}
However i’m always getting an exception saying the element isn’t interactable.
I don’t have any tags along the HTML code, neither submit. All i have is this button.
I’ve read a lot of sites on SO (thats why i managed to get so far) but i still can’t click this button.
Something i’ve tought of was to get its location and click by using JavaScript on its coordinates. Could this be a proper solution?
I would basically need to get the button with the text “CONSULTAR PRODUTO” and click on it. I’ve also tried to reach the button by using its XPath:
var consultarProdutoButton = driver.FindElement(By.XPath("//button[contains(text(), 'CONSULTAR PRODUTO')]"));
consultarProdutoButton.Click();
BUt this didn’t worked also.
Any input is appreciated, thanks a lot.