I'm running code for a python selenium project and I get this error.
DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead driver.find_element_by_xpath("//button[@aria-label='Play']").click()
This is my code:`
from kameleo.local_api_client.kameleo_local_api_client import KameleoLocalApiClient
from kameleo.local_api_client.builder_for_create_profile import BuilderForCreateProfile
from kameleo.local_api_client.models.problem_response_py3 import ProblemResponseException
from kameleo.local_api_client.models.server_py3 import Server
from selenium import webdriver
import json
kameleoBaseUrl = "http://localhost:5050"
client = KameleoLocalApiClient(kameleoBaseUrl)
base_profiles = client.search_base_profiles (
device_type='desktop',
browser_product='chrome',
language='en-us'
)
create_profile_request = BuilderForCreateProfile \
.for_base_profile(base_profiles[0].id) \
.set_recommended_defaults() \
.set_proxy('http', Server(host='dctrial.us.razorproxy.com', port=11079, id="rzt_gzNYK", secret="EJiWKB8cgx")) \
.build()
profile = client.create_profile(body=create_profile_request)
client.start_profile(profile.id)
options = webdriver.ChromeOptions()
options.add_experimental_option('kameleo:profileId', profile.id)
driver = webdriver.Remote(
command_executor=f'{kameleoBaseUrl}/webdriver',
options=options
)
driver.get('https://www.youtube.com/watch?v=rz19gAuaVFI&t=72s')
driver.find_element_by_xpath("//button[@aria-label='Play']").click()
I tried to do as the code said but it still didn't work.