Question

I am trying to find the table having ID using Selenium WebDriver but unable to do so, getting error as follows:

Unable to find element

Could someone please suggest, what am I doing wrong ?

<table id="{EB2E32F8-B236-42CD-9425-49BB4EA9DB01}-{A85091D3-69F3-419D-98EE-0FEBD1C3CC65}" class="ms-listviewtable" cellspacing="0" cellpadding="1" border="0"  onmouseover="EnsureSelectionHandler(event,this,11)" dir="none" o:webquerysourcehref="&XMLDATA=1&RowLimit=0&View=%7BA85091D3%2D69F3%2D419D%2D98EE%2D0FEBD1C3CC65%7D" xmlns:o="urn:schemas-microsoft-com:office:office" summary="CloneConfiguration" onmousedown="return OnTableMouseDown(event);" handledeleteinit="true">

I am trying to find the table using ID

driver.findElement(By.id("{EB2E32F8-B236-42CD-9425-49BB4EA9DB01}-{A85091D3-69F3-419D-98EE-0FEBD1C3CC65}"));

Any Idea ?

Was it helpful?

Solution

Seems like id is not static. you can try to get it by classname. i.e.

driver.findElement(By.className("ms-listviewtable"));

OTHER TIPS

You can try xpath to locate the element using below code snippets:

Code snippet 1:

driver.findElement(By.xpath("//table[@class='ms-listviewtable']"));

Code snippet 2:

driver.findElement(By.xpath("//table[@summary='CloneConfiguration']"));

Code snippet 3:

driver.findElement(By.xpath("//table[@onmousedown='return OnTableMouseDown(event);']"));

Code snippet 4:

driver.findElement(By.xpath("//table[@onmouseover='EnsureSelectionHandler(event,this,11)']"));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top