Selenium php-webdriver check attribute after click -
<a class="lnk" href="http://www.google.com">go google</a>
when click on link, css class 'loading' append. how test before redirecting google.com.
$element = $driver->findelement(webdriverby::classname('lnk')); $element->click();
is there way check class attribute contains 'loading' before redirecting destination?
you can use javascript edit href
attribute , add timeout
$element = $driver->findelement(webdriverby::classname('lnk')); $href = $element->getattribute('href'); $script = "javascript:settimeout( function() { window.location = {$href} }, 5000 );" $driver->executescript("arguments[0].setattribute('href', arguments[1]);", $element, $script);
now yo have enough time check if class
attribute contains loading
$element = $driver->findelement(webdriverby::classname('lnk')); $class = $element->getattribute('class'); if (strpos($class, 'loading') !== false) { }
Comments
Post a Comment