6

To add explanation to what you have already figured out. The problem was that with this line you correctly acquired the second row: IWebElement secondRow = driver.FindElement(By.CssSelector("table tr:nth-of-type(2)")); but with the next piece of code, you did not get the 4th cell of the second row, but the first 4th cell of the DOM and that starts from the ...


3

From the link you provided, library is still there and you are free to use it. With disclaimer that it is no longer maintained, and possible there could be other such libraries with more community support, which would be better, more future-proof candidates to base your design on. Originally, it seems that this code was intermixed with other .NET code for ...


3

I do not have a separate TestBase/Service class for each test. I have just Page Object classes which contain the page factory and unit test classes which contain the test methods. Is this approach correct? Without seeing code, hard to picture exactly what you mean here, but, I feel you should separate your page factory classes from your unit test classes. ...


3

This is one of my Page Objects. It works perfectly fine. public class MyHomePage { IWebDriver driver = null; [FindsBy(How = How.LinkText, Using = "Home"), CacheLookup] public IWebElement lnkHomeTab { get; set; } [FindsBy(How = How.TagName, Using = "Title"), CacheLookup] public IWebElement pageTitle { get; set; } public MyHomePage(...


2

From the question you posed I assume that you didn't start with a testing framework and are trying to build your own, you have the built in Unit Test Framework but not the all the classes for Clicking buttons with certain text or a certain ID or whatever. you should start with smaller classes that will extend functionality. like you will want a class that ...


2

Additionally, is there a better/different way to incorporate Page Objects without using Page Factory? PageFactory initializes the elements and isn't altogether necessary if you change your defined elements to getters. This allows you to use a "fluent POM" model if you setup your element to be a property of the page and the page in the "App". App is a class ...


2

You cannot take full page screenshots with Selenium/WebDriver. The WebDriver W3C requirement specify taking screenshots as: The Take Screenshot command takes a screenshot of the top-level browsing context’s viewport. So you can only take screenshots of what is currently visible. I don't think there are a lot of use-cases where during a test you need a ...


2

Well, actually I strongly not recommend to use the solution posted below unless you have clear understanding of what you're doing and why you do really need this since injecting changes into the actual page might decrease the quality of your tests: Check this post to learn how to run JavaScript against the pages using Selenium in C#. Check this post to ...


2

I am not a C# guy, I can help you with a basic idea how you can achieve this with pseudo-code, then you can translate the same in C#. Add all the check boxes to list. Loop thru the list to check which of them is not selected. If not selected, perform a click to select that checkbox. List<WebElement> _all_check_box = new ArrayList<WebElement&...


2

The problem is the element you are working on is NOT embedded in a select tag, so you can't use Select class on that element. When you use a Select class, a check is made that the given element is, indeed, a SELECT tag. If it is not, then an UnexpectedTagNameException is thrown. So, what you can do is: Identify the locator for the element. Perform ...


2

Change var tmpName = webBlock.FindElement(By.XPath("//h2[contains(@id, 'attr-name')]")).Text; to var tmpName = webBlock.FindElement(By.XPath(".//h2[contains(@id, 'attr-name')]")).Text;. This should work (see details here).


2

I made the following change and it worked: portalweb = secondRow.FindElement(By.CssSelector("td:nth-of-type(4)")).Text;


2

There is syntax error in your xPath expression, an opening [ is missing and after the @ the attribute name is also missing. All in all it should be: //select[@name='opcao_pesquisa']


2

The standard package manager for C# / .Net is NuGet More details on the setup and management process for Visual Studio here.


1

I am not sure this contains(@class="login_button") is a proper xpath syntax (however since you're not mentioning parse errors looks like it is) at least for your task. Try: //*[contains(@tabindex,"3") and contains(@class, "login_button")] //input[contains(@tabindex,"3") and contains(@class, "login_button")] //input[@name='@COMMAND_EVENT@'][@tabindex='3'] ...


1

I would try to disable the save as functionality: ChromeOptions options = new ChromeOptions(); options.AddUserProfilePreference("download.default_directory", @"C:\Users\Usernname\Downloads\"); options.AddUserProfilePreference("download.prompt_for_download", false); driver = new ChromeDriver(options); Now files will be directly downloaded, without the save ...


1

As you have a lot of inputs I suggest filtering for the type of the input, in this case for button. Then you can narrow down the buttons based on their value attribute. In your case the xpath expression should look like this: //form//input[@type='button' and contains(@value,'Pesquisar')] You can use it to find an element by xpath from your test like: ...


1

I think you are more aiming towards finding a correct locator for the desired button. You might consider using the below xpath: //form//input[contains(text(), 'Pesquisar')] in findElement by xpath as the locating strategy.


1

I recently replaced all our Wait.Until(ExpectedConditions.ElementToBeVisible(By.IDK(element)) to Wait.Until(driver => driver.FindElement(By.IDK(element)).IsVisible());


1

It looks like you've got the elements OK, but you can't convert elements to strings. You need to use the .Text property to get the text from the element, and then use C#'s string functions to get what you need out of it. string clientName = client.Text; int portalNumber = Int32.Parse(portal.Text); int nomeDePortalNumber = Int32.Parse(System.Text....


1

You can write a generic xPath expression to get the value of the marked columns in an array even for multiple rows like: //tr[boolean(position() != 1)]/td[position() = 3 or position() = 4 or position() = 5] This expression will skip the first row, which is the header, and then return the value of column 3, 4 and 5 for the rest of the table. // Find ...


1

First of all, we need to find the second row: IWebElement secondRow = driver.FindElement(By.CssSelector("tr:nth-of-type(2)")); Then, you can find each element by position: IWebElement client = secondRow.FindElement(By.CssSelector("td:nth-of-type(3)")); IWebElement portal = secondRow.FindElement(By.CssSelector("td:nth-of-type(4) a")); IWebElement ...


1

I have used https://www.imagemagick.org for image compare. They have a Nuget package which you can add to your project and you can write code similar to below in C# or F# let img1 = new MagickImage(Image1Path) let img2 = new MagickImage(Image2Path) let img3 = new MagickImage() let diff = img1.Compare(img2, ErrorMetric.Absolute, img3) ...


1

Before accessing the page source, I refreshed the driver. driver.Navigate().Refresh(); This refreshes the DOM element too, (I guess).


1

First verify the checkbox is already selected or not by using the if condition. Use this below code boolean iconEnabled = driver.findElement(By.id("1")).isEnabled(); if(iconEnabled == true) { WebElement checkbox = driver.findElement(By.id("1")); checkbox.click(); }


1

As per the code shared,I think in your SetUpBrowser function, you may implement a switch block where you will initialize the specific browser instance of browser type passed from config file. In the same block, you will also add any browser specific steps/settings after object intialization. After that, rest of the framework does not need to know which ...


1

You can extend your code to run any browser you have webdriver files for. That's all you need. Webdrivers can send commands to their respective browsers. You may need to find and download additional webdrivers. Where is the part you read the value of BrowserType from app.config? If there isn't, you should implement it. Modify your ...


1

Got it working by waiting for all cells to be visible using the below, wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(By.CssSelector("td role = gridcell")));


1

You can use NuGet package which is in two forms, one is called DotNetSeleniumExtras.PageObjects and other one DotNetSeleniumExtras.WaitHelpers.


1

string mystring; IList<IWebElement> mylist; Thread.Sleep(2000); //Search Table mylist = driver.FindElements(By.XPath(Table)); if (mylist.Count >= 1) { foreach (IWebElement ele in mylist) { mystring = ele.Text; if (mystring == "your text") { Thread.Sleep(3000); driver.FindElement(By.LinkText(...


Only top voted, non community-wiki answers of a minimum length are eligible