With the following code, I tried to submit list of genes to the website and perform some analysis.
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
driver = webdriver.Firefox()
driver.implicitly_wait(10)
genes = "Eif2ak2,Pcgf5,Vps25,Prmt6,Tcerg1,Dnttip2,Preb,Polr1b,Gabpb1,Prdm1,Fosl2,Zfp143,Psip1,Kat6a,Tgif1,Txn1,Irf8,Cnot6l,Zfp451,Foxk2,Lpxn,Etv6,Khsrp,Lmo4,Nkrf,Mafk,Mbd1,Cited2,Elp5,Jdp2,Bzw1,Rbm15b,Klf9,Gtf2e2,Dynll1,Klf6,Stat1,Srrt,Gtf2f1,Adnp2,Ikbkg,Mybbp1a,Nup62,Brd2,Chd1,Kctd1,Sap30,Cebpd,Mtf1,Gtf2h2,Fubp1,Tcea1,Irf2bp2,Ezh2,Hnrpdl,Pml,Cebpz,Med7"
targetmine_url = "http://ift.tt/1Fn8sMt"
driver.get(targetmine_url)
# Define type of list to be submitted
gene_select = Select(driver.find_element_by_name("type"))
gene_select.select_by_visible_text(u"Gene")
# Enter list and submit
gene_input = driver.find_element_by_id("listInput")
gene_input.send_keys(genes)
submit = driver.find_element_by_css_selector("input.button.light").click()
driver.switch_to_frame("__pomme::0")
driver.find_element_by_css_selector("span.small.success.add-all.button").click()
driver.find_element_by_css_selector("a.success.button.save").click()
driver.find_element_by_xpath("//ul[@id='customConverter']/li[2]/a[1]").click()
Up to that point above, it works fine. Then I'd like to access certain element of the file as shown below
But why this command failed:
# Gene Ontology enrichment part
go_xpath = "//div[@id='gene_go_enrichment-widget']/div[1]/div[1]/div[1]/div[4]/form[1]/div[2]/select[2]/option[3]"
go_select = Select(driver.find_element_by_xpath(go_xpath))
The error message I got is this:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//div[@id='gene_go_enrichment-widget']/div[1]/div[1]/div[1]/div[4]/form[1]/div[2]/select[2]/option[3]"}
Aucun commentaire:
Enregistrer un commentaire