find elements Test NUnit Visual Studio 2022
This commit is contained in:
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,51 @@
|
||||
using OpenQA.Selenium.Firefox;
|
||||
using OpenQA.Selenium;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SeleniumNunitProject.Tests
|
||||
{
|
||||
internal class FindElementTest
|
||||
{
|
||||
[Test]
|
||||
public void LocatorsTest()
|
||||
{
|
||||
var results = new List<string>();
|
||||
IWebDriver driver = new FirefoxDriver();
|
||||
driver.Manage().Window.Maximize();
|
||||
driver.Navigate().GoToUrl("https://www.selenium.dev/");
|
||||
Assert.That(driver.Title, Is.EqualTo("Selenium"));
|
||||
|
||||
// h2 element mánastránce více prvků oproti h1
|
||||
// FindElement --> načte první h2 v seznamuna stránce
|
||||
var firstH2 = driver.FindElement(By.XPath("//h2"));
|
||||
results.Add($"FindElement: {firstH2.Text}");
|
||||
|
||||
// FindElements --> vrátí všechny elementy h2 na stránce
|
||||
var h2Collection = driver.FindElements(By.XPath("//h2"));
|
||||
foreach ( var h2 in h2Collection )
|
||||
{
|
||||
results.Add($"FindsElements: {h2.Text}");
|
||||
}
|
||||
|
||||
// evaluate a subset of the DOM
|
||||
var parentElement = driver.FindElement(By.CssSelector("div[id='main_navbar']"));
|
||||
var links = parentElement.FindElements(By.TagName("a"));
|
||||
foreach ( var link in links )
|
||||
{
|
||||
var result = link.Text;
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
results.Add($"links: {link.Text}");
|
||||
}
|
||||
}
|
||||
File.WriteAllLines("results", results);
|
||||
|
||||
driver.Quit();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace SeleniumNunitProject.Tests
|
||||
// xpath (text na hlavní straně h1)
|
||||
var xpathVAlidator = driver.FindElement(By.XPath("//h1")).Displayed;
|
||||
Assert.That(xpathVAlidator, Is.EqualTo(true));
|
||||
Console.WriteLine(xpathVAlidator);
|
||||
|
||||
|
||||
driver.Quit();
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
1202625413
|
||||
54692754
|
||||
@@ -0,0 +1,13 @@
|
||||
FindElement: Getting Started
|
||||
FindsElements: Getting Started
|
||||
FindsElements: Selenium Level Sponsors
|
||||
FindsElements: News
|
||||
FindsElements: Support the Selenium Project
|
||||
FindsElements: Donate to Selenium
|
||||
links: About
|
||||
links: Downloads
|
||||
links: Documentation
|
||||
links: Projects
|
||||
links: Support
|
||||
links: Blog
|
||||
links: English
|
||||
+1
-1
@@ -1 +1 @@
|
||||
01e6d31dbbd36b9b44f8740f275982f004b85ddc
|
||||
4ad791b70820c50a5fd253c54ea166f7eb25c24e
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Reference in New Issue
Block a user