0
I am using Selenium + Chrome Webdriver and php to scrape data from a website and, for that, I need to make a condition with the width of a column of a table of that site. I do it 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 the size to me in object form. As shown in two shapes 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] => 0 )
I only want 0, which is the width of the element. How do I get it?
Addend1: When I try to use the function getWidth()
. This error is generated (which I only have access to by the.log php 7 file):
PHP Fatal error: Uncaught Error: Call to Undefined method Facebook Webdriver Remote Remotewebelement::getWidth() in /var/www/html/Inpi/Crawler.php:92 nStack trace: n#0 {main} n thrown in /var/www/html/Inpi/Crawler.php on line 92
Addend2: No css defined in tag for me to use getAttribute('width')
. Still I tried and it didn’t work.
I’ve tried, but nothing comes back :(
– user87737
I added the code I used at first
– user87737