I wanted to search for a particular version of seldon-core (1.7.0) ( https://pypi.org/) . I have reached (using selenium) till the release history page(https://pypi.org/project/seldon-core/#history) but not able to search for particular version (1.7.0).
I wanted to search that whole list(all versions are contained inside the list) for a version match.
PS: the list has div id as "history" and further it has subclasses in which version number is mentioned.
CodePudding user response:
To search for a particular version of seldon-core e.g. 1.7.0
within seldon-core . PyPI History page you need to induce WebDriverWait for the visibility_of_all_elements_located() and you can use the following Locator Strategy:
Code Block:
driver.get("https://pypi.org/project/seldon-core/#history") text = "1.7.0" if(text in element.text for element in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "p.release__version")))): print("Version found") else: print("Version not found") driver.quit()
Console Output:
Version found
Update
If you want to search a list for a version match you can use:
Code Block:
driver.get("https://pypi.org/project/seldon-core/#history") versions_search = ["1.8.2", "1.9.2", "1.7.0"] versions_available = [element.text for element in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "p.release__version")))] if any(x in versions_search for x in versions_available): print("Version match found") else: print("Version match not found") driver.quit()
Console Output:
Version match found