How to find an item in Selenium WebDriver?

selenium find element by class java
selenium find element by xpath
find element by xpath selenium java
selenium find element by css selector
how to get all the elements in a page using selenium webdriver
selenium find element by text
findelements selenium c#
selenium find element by attribute

I want to find the following item using Selenium. The value of the class changes whenever there is a change. This is inside a complex page (multiple iframes, and other items loaded dynamically). The only unique id is itemid, which is dynamic value and title combination. If I click on this Action, am getting another new set of complex items. I am new to Selenium. How to do that?

HTML:

<td itemid="xxyyy.as123" title="Actions" nowrap="" class="text-button">Actions&nbsp;<img src="../row.gif"></td>

<td itemid="xxyyy.as123" title="Actions" nowrap="" class="text-button button-active">Actions&nbsp;<img src="../row.gif"></td>

<td itemid="xxyyy.as123" title="Actions" nowrap="" class="text-button button-hover">Actions&nbsp;<img src="../row.gif"></td>

The code I tried:

  1. Find by Xpath

    var element=driver.FindElement(By.XPath("html/body/div[id='pageContent']/iframe/#document/ht‌ml/frameset/frame[name='detailsDisplay']/#document/html/body/form[name='tableForm‌']/div[id='divToolbarContainer']/div[id='divToolbar']/div[1][class='toolbar']/tab‌​le/tbody/tr/td[title='Actions']"));
    
  2. Find by Link Text

    var element = driver.FindElement(By.LinkText("Actions"));
    

Any help would be appreciated.

Try

 By.CssSelector("td[title="Actions"]");
 By.CssSelector("td[itemid="xxyyy.as123"]");
 By.CssSelector("td[itemid="xxyyy.as123"][title="Actions"]")

How to Find Elements in Selenium WebDriver, Find Element in Selenium using By Strategy. Finding elements in Selenium WebDriver is done by using the findElement(By.locator()) method. I want to find the following item using Selenium. The value of the class changes whenever there is a change. This is inside a complex page (multiple iframes, and other items loaded dynamically). The only unique id is itemid, which is dynamic value and title combination. If I click on this Action, am getting another new set of complex items.

Create Dynamic CSS Selector.

For Example:

driver.FindElement(By.CssSelector("td[itemid$="xxyyy."]")).Click(); 

Note: In dynamic Elements, there is always a part of locator wich is fixed. we need to generate the locator using this part.

  1. If fixed part is at starting - Use Carrot Character (^)
  2. If fixed part is at Middle - Use Asterisk sign (*)
  3. If fixed part is at End - Use Doller sign ($)

How to find element in Selenium using FindElement Command?, WebDriver offers a number of built-in selector types, amongst them finding an element by its ID attribute: Java Python C# Find Elements in Selenium WebDriver: Locator Strategy/ Types of locators Locator Strategy can be one of the following types to find an element or FindElements

Finally I was able to achieve it, by using the frame names.

 driver.SwitchTo().Frame("content").SwitchTo().Frame("detailsDisplay");                        
 var element = driver.FindElement(By.XPath("//*[@id=\"divToolbar\"]/div[1]/table/tbody/tr/td[1]"));

Thanks everyone.

Locating elements :: Documentation for Selenium, Most often, such automated testing is executed by using frameworks like Selenium WebDriver. Selenium defines two methods for identifying web  We will learn how to find multiple elements in a list and how to use them in a for loop. ***** Complete Test Automation Bundle ($29 Only): Includes 9 Courses, future new test and automation

Find Element and FindElements in Selenium : Differences , Selenium WebDriver provides different methods to locate elements on a For example, if we wanted to find an h1 heading element on a page,  Selenium webdriver once again comes to our rescue! It provides Select class with pre-defined methods specially for handling dropdowns and multiple selection scenarios. Step 1: This select class is available in “org.openqa.selenium.support.ui.Select” package.

Selenium - Locating Web Elements, from selenium.webdriver.common.by import By driver.find_element(By.XPATH You can use XPath to either locate the element in absolute terms (not advised),  x y coordinates of a web element is measured in x and y pixels. x pixels means the horizontal position of an element on a page from the left side and y pixels means the vertical position of an element on a page from the top. Let’s see how to find web elements x y coordinates using Selenium WebDriver.

4. Locating Elements, The key here is to find the most stable and reliable locator for each element. Keep in mind that asking Selenium to locate an element is like  Use Selenium to select an option from an Input element with multi-select drop-down 2 How to Select a value from Dropdown using Selenium WebDriver (Java) having input and div but not select tag?

Comments
  • Until you switch to correct frame, you cannot perform any action on element.
  • This page is having around 10 iframes, and other elements. How do I get the right frame?
  • Are frames change dynamically?
  • Under which iframe, the element that you are trying to click comes? is that static atleast?
  • Enter web page is dynamically updated.
  • Its full of numbers. so no clue.