Я щелкнул правой кнопкой мыши на радиоурочно-код>, а затем я выбрал , чтобы получить код HT. /> Это то, что показывает код HTML: < /p>
Код: Выделить всё
User
< /code>
In the same manner, I have right-clicked on Admin
And the HTML code looks exactly the same as that of User:
Код: Выделить всё
Admin
< /code>
Admin
using OpenQA.Selenium.Chrome;
using WebDriverManager.DriverConfigs.Impl;
using OpenQA.Selenium.Support.UI;
namespace SeleniumLearning
{
public class FunctionalTest
{
IWebDriver driver;
[SetUp]
public void StartBrowser()
{
new WebDriverManager.DriverManager().SetUpDriver(new ChromeConfig());
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "https://rahulshettyacademy.com/loginpagePractise/";
}
[Test]
public void radiobutton()
{
Thread.Sleep(1000);
IWebElement radiobutton = driver.FindElement(By.Id("usertype"));
SelectElement s = new SelectElement(radiobutton);
s.SelectByValue("user");
}
}
}
< /code>
And, I have received the following error:
OpenQA.Selenium.Support.UI.UnexpectedTagNameException : Element should have been select but was input
Then I tried with this code:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using WebDriverManager.DriverConfigs.Impl;
using OpenQA.Selenium.Support.UI;
namespace SeleniumLearning
{
public class FunctionalTest
{
IWebDriver driver;
[SetUp]
public void StartBrowser()
{
new WebDriverManager.DriverManager().SetUpDriver(new ChromeConfig());
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Url = "https://rahulshettyacademy.com/loginpagePractise/";
}
[Test]
public void radiobutton()
{
Thread.Sleep(1000);
IWebElement radiobutton = driver.FindElement(By.ClassName("radiotextsy"));
SelectElement s = new SelectElement(radiobutton);
s.SelectByValue("user");
}
}
}
< /code>
And it is showing the same error message:
Message:
OpenQA.Selenium.Support.UI.UnexpectedTagNameException : Element should have been select but was input
I'm still trying to figure out where I'm making the mistake.
Would be very helpful, if a simple code is provided to fix this issue.
Подробнее здесь: https://stackoverflow.com/questions/796 ... io-buttons