selenium谷歌无头模式和phantomjs

我在用谷歌有头模式点击网页可以正常点击访问 于是我又用phantomjs就报元素不存在(这里用的是老版本的) 然后我又用谷歌无头模式访问 也能正常访问
这是为什么呢?

import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def start():
    #targets = Options()
    #targets.add_argument('--headless')
    #targets.add_argument('--disable-gpu')
    path = r'chromedriver.exe'
    name=input('搜索:')
    muscienc=f'https://www.musicenc.com/?search={name}'
    #target=webdriver.Chrome(executable_path=path,chrome_options=targets)
    target=webdriver.PhantomJS('phantomjs.exe')
    target.get(muscienc)
    target.implicitly_wait(6)

    target.find_element_by_xpath('/html/body/div[2]/div[2]/li[1]/a').click()
    time.sleep(5)
    allhandle=target.window_handles
    target.switch_to.window(allhandle[1])
    time.sleep(5)
    open=target.find_element_by_xpath('/html/body/div[2]/div[3]/a')
    open.click()
if __name__ == '__main__':




    start()


之前我也遇到过这个问题,原因是新版的selenium已经不在支持phantomjs,降低selenium版本即可
这是我的解决过程
https://blog.csdn.net/m0_61791601/article/details/123195170?utm_source=app&app_version=5.3.1&code=app_1562916241&uLinkId=usr1mkqgl919blen