I'm using Selenium + Chrome WebDriver and php to wipe data from a website, and for that I need to make a condition with the width of a column of a table on that site. I do this with the following code:
$td3 = $driver ->findElement(WebDriverBy::xpath('/html[1]/body[1]/form[1]/div[2]/div[1]/table[2]/tbody[1]/tr[5]/td[3]')) -> getSize();
Only Selenium returns me the size in object form. As shown in two forms below.
With var_dump
:
object (Facebook \ WebDriver \ WebDriverDimension) # 19 (2) {["height": "Facebook \ WebDriver \ WebDriverDimension": private] = > int (38) ["width": "Facebook \ WebDriver \ WebDriverDimension": private] = > int (0)}
With print_r
:
Facebook \ WebDriver \ WebDriverDimension Object ([height: Facebook \ WebDriver \ WebDriverDimension: private] => 38 [width: Facebook \ WebDriver \ WebDriverDimension: private] = >
I want only 0, which is the width of the element. How do I get there?
Addendum1: When I try to use the getWidth()
function. This error is generated (that I only have access by the error.log file of php 7):
PHP Fatal error: Uncaught Error: Call to undefined method
main} \ n thrown in /var/www/html/inpi/crawler.php on line 92
Addendum2: There is no css defined in the tag so I can use getAttribute('width')
. But I tried and it did not work out.