You need to pass the video title as a variable instead of as text, as displayed in the code below:
video_title = 'Michael Jackson - Thriller'
driver.find_elements_by_xpath("//*[contains(text(), '" + video_title + "')]")
Note the extra single quote around video_title
, required because it's a string. At runtime this will result in the following XPath expression:
//*[contains(text(), 'Michael Jackson - Thriller')]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…