The HTML I am attempting working with is under,
MUFC
Manchester United
23/10/2017
1
Bill
1000
5.00
1.00
SA
6.00
0.00
2017
1
23/10/2017
23/10/2017
0.00
Clicking the under opens a modal window however I am struggling to get the clicking to work,
MUFC
Because the desk is dynamic I do not suppose I can use the XPath, the code at current seems like this,
driver.FindElement(By.ClassName("cell-popover")).Click on();
Which works nice so long as the cell is on the primary row of the desk, nevertheless this is not going to all the time be the case so would love some advicehelp on methods to proceed?
UPDATE
Solved it with this,
IWebElement elemTable = driver.FindElement(By.Id("enquiry-header-grid-SalesTransactionEnquiry-enquiry-header-grid-wrapper")).FindElement(By.TagName("tbody"));
Record lstTrElem = new Record(elemTable.FindElements(By.TagName("tr")));
IWebElement row = lstTrElem.The place(merchandise => merchandise.Textual content.Accommodates("LU1")).FirstOrDefault();
string rowid = row.GetAttribute("data-uid");
IList cells = row.FindElements(By.TagName("td"));
for (int i = 0; i < cells.Rely; i++)
{
IWebElement cell = cells[i];
}
row.FindElement(By.ClassName("cell-popover")).Click on();
Because the td containing "LU1" is all the time distinctive, be intersted to know if there's a extra efficientreliable means of doing it although!
Second Replace
Refined it barely to the next,
IWebElement elemTable = driver.FindElement(By.Id("enquiry-header-grid-SalesTransactionEnquiry-enquiry-header-grid-wrapper")).FindElement(By.TagName("tbody"));
Record lstTrElem = new Record(elemTable.FindElements(By.TagName("tr")));
IWebElement row = lstTrElem.The place(merchandise => merchandise.Textual content.Accommodates("LU1")).FirstOrDefault();
string rowid = row.GetAttribute("data-uid");
row.FindElement(By.ClassName("cell-popover")).Click on();
Appears to be dependable
5
both
By.LinkText("MUFC")
orBy.CssSelector("[data-col-name='ST_COPYCUST']")
orBy.XPath("//a[normalize-space()='MUFC']")
. You might want to make use of a waiter if the content material is created dynamically.Commented
Mar 15, 2018 at 18:48
The issue with these approaches is that the LinkText "MUFC" for that column is not going to be distinctive so i must specify the row to seek out the LinkText in - I used to be considering of attempting to make use of the
Commented
Mar 15, 2018 at 23:37
What's the precise error you're getting in different dynamic circumstances?
Commented
Mar 16, 2018 at 7:35
As I perceive , there is just one hyperlink going to be in any case within the desk (solely row can differ),if sure then object is exclusive so what's the subject right here?
Commented
Mar 16, 2018 at 7:37
Glad to shut this as my implementation appears dependable, thanks for the feedback and solutions!!
Commented
Mar 16, 2018 at 19:06
2 Solutions
Why not merely attempt the under,
answered Mar 16, 2018 at 7:52
5,57322 gold badges1919 silver badges3737 bronze badges
If I am understanding this proper, that is standards we are able to rely on?:
"LU1"
Then this XPath may match:
This could discover the primary tr that comprises textual content with "LU1" (within the elemTable), then provide the first youngster td in that tr that has class of "cell-popover".
answered Mar 16, 2018 at 1:16