protected $_groupCollection;
public function __construct(
......
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory $_groupCollection
.....
) {
.....
$this->_groupCollection = $_groupCollection;
.....
}
.
public function getAttributeGroupId($attributeSetId)
{
$groupCollection = $this->_groupCollection->create();
$groupCollection->addFieldToFilter('attribute_set_id',$attributeSetId);
$groupCollection->addFieldToFilter('attribute_group_name','Testing'); // here you can add your attribute code
return $groupCollection->getFirstItem();
}
now in phtml file
$groupid=$block->getAttributeGroupId($product->getAttributeSetId());
$productAttributes=$product->getAttributes();
foreach ($productAttributes as $attribute):
if ($attribute->isInGroup($product->getAttributeSetId(), $groupid->getAttributeGroupId())):
if($attribute->getFrontend()->getValue($product)):
echo $attribute->getFrontendLabel().' : '.$attribute->getFrontend()->getValue($product).'<br />';
endif;
endif;
endforeach;