$product->setName('name'); or $product->setWeight('weight); all are working. I created a custom attribute 'color' and it has two values 'Black' and 'White' as options. How can I set product's color to white when I save the product? Thank you.
You need to set option value not an option label of that custom attribute. you can simply identify that option value using developer console.
See this image you will have a better idea. : https://prnt.sc/iodyll