java - Selecting individual parts of cell <td> using Selenium -


I started using Selenium to collect data from a website that uses JavaScript. I have worked at a point where I am able to select cells from the table, but now I want to be able to select the "personal" string from each cell, for example:

A cell from this table:

  & lt; Tr data-ig = "x: 360964033.17: adr: 0: tag:" tag = "" adr = "0" type = "row" & gt; & Lt; Td idx = "0" adr = "0" type = "cell" & gt; 2014-11-02 21: 15: 00 & lt; / Td> & Lt; Td idx = "1" adr = "1" type = "cell" & gt; AMALT & lt; / Td> & Lt; Td idx = "2" adr = "2" type = "cell" & gt; 60007 & lt; / Td> & Lt; Td idx = "3" adr = "3" type = "cell" & gt; 107115 & lt; / Td> & Lt; Td square = "ig9a63765d" & gt; 1 & lt; / Td> & Lt; Td idx = "9" adr = "9" type = "cell" & gt; 576833 & lt; / Td> & Lt; / TR & gt;  

I & lt; Td idx = "0" adr = "0" type = "cell" & gt; 2014-11-02 21: I would like to be able to select / 15: 00 & lt; / Td> Lines individually in the cell, how is this possible? I want to be able to do something like this list & lt; WebElement & gt; AllRows = table.findElements (By.tagName ("idx = 0")); but it does not work

I am collecting the table and cells completely like this:

  // Now the table lists all the TR elements Get & lt; WebElement & gt; AllRows = table.find elements (By.tagName ("tr"); // and iterative over, the cells are getting (WebElement line: allRows) {list & lt; WebElement & gt; Cells = row. Filled elements (Baiyangn ("TD")); // Print the contents of each cell (WebElement cell: Cells) {System.out.println (cell.getText ()); }break; }  

Thanks.

The update has changed to a table layout:

  & lt; Tr data-ig = "x: 360964033.17: ad: 0: tag:" tag = "" adr = "0" type = "row" & gt; & Lt; Td> 2014-11-04 23: 00: 00 & lt; / Td> & Lt; Td idx = "1" adr = "1" type = "cell" & gt; GadgetsGod & lt; / Td> & Lt; Td idx = "2" adr = "2" type = "cell" & gt; 11344 & lt; / Td> & Lt; Td idx = "3" adr = "3" type = "cell" & gt; 14500 & lt; / Td> & Lt; Td idx = "4" adr = "4" type = "cell" & gt; Saddasd & lt; / Td> & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; Sdsed & lt; / TD & gt; & Lt; TD & gt; Dsfdsf & lt; / TD & gt; & Lt; Td square = "ig9a63765d" & gt; 1 & lt; / Td> & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt;  

Does the table layout change?

In your example, idx is not a tag, it is a feature . In Selenium you can select based on the attribute using XPath:

  table.findElement (By.xpath ("// td [@ idx = 0]"))  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -