Untitled
unknown
plain_text
9 months ago
1.7 kB
11
Indexable
using OpenQA.Selenium;
using OpenQA.Selenium.Support.PageObjects;
using OpenQA.Selenium.Support.UI;
using SeleniumExtras.WaitHelpers;
using System;
public class CMOTextSection
{
private readonly IWebDriver driver;
private readonly WebDriverWait wait;
public CMOTextSection(IWebDriver driver)
{
this.driver = driver;
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
PageFactory.InitElements(driver, this);
}
[FindsBy(How = How.CssSelector, Using = "div.swh-cluu-controls-html-input-editor[contenteditable='true']")]
private IWebElement TaskDescriptionHereField;
private By TextVariantVorwaertsGerichtetBy =>
By.XPath("//td[contains(@class,'MuiTableCell-body')]//div[normalize-space()='Vorwärts gerichtet']/ancestor::td[1]");
public void SelectHereTaskDescription()
{
WaitForElement(TaskDescriptionHereField);
TaskDescriptionHereField.Click();
var optionCell = wait.Until(ExpectedConditions.ElementExists(TextVariantVorwaertsGerichtetBy));
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView({block:'center'});", optionCell);
try
{
wait.Until(ExpectedConditions.ElementToBeClickable(optionCell));
optionCell.Click();
}
catch (ElementClickInterceptedException)
{
((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", optionCell);
}
}
private void WaitForElement(IWebElement element)
{
wait.Until(d => { try { return element.Displayed && element.Enabled; } catch { return false; } });
}
}Editor is loading...
Leave a Comment