I've seen i am not the only one having this issue, i've tried several of the solutions proposed in another questions here but i just wanted to share my method.
First of all i had this trouble both when installed only Ubuntu (HP Pavilion 15) and then when trying dual boot options with Win10 (having no issues at all with Windows10 WiFi configuration and the Atheros Broadcom driver)
My solution for the issue was to go to the "Additional Drivers" section in "Software and Updates" window after making both sudo apt-get update and sudo apt-get upgrade, there i had two options for the WiFi driver, the one i needed and the "Do not use the device" option marked. Once i tried to mark the actual driver i needed a problem pops-up saying that i needed to disable secure boot from BIOS, which is only to go BIOS configuration (turn latop on, and press F10) and disable the secure boot option.
It seems the prevention was because the Realtek WiFi driver for my laptop is considered a third party driver and the system itself prevents it from being the default option and i don't know if this could lead to some future issues with the OS or the dual boot i am implementing in this machine, i am no expert but at least my WiFi works again.
Hope it could help someone in need, I would like to read you experts about my method and the potential dangers about it.