2015-11-04 111 views
1

請打開此網站-https://mobikwik.com/
有一個移動與第二項作爲選擇運算符的表單。
我想選擇 - 從這個下拉使用硒webdriver的「理念」。
請幫忙。Python selenium從角度js下拉選擇選項

此外,選擇想法後,我得到一個新的選擇圓下拉。需要選擇孟買。

我嘗試:

driver.find_element_by_css_selector("li > span.ng-binding").click() 
driver.find_element_by_xpath("//label[3]/i").click() 
driver.find_element_by_css_selector("font > label > i").click() 
driver.find_element_by_xpath("//section[@id='mainunit']/div/div[2]/div/div[2]/div/div/div/form/div[4]/p/dl/dd/ul/li[9]/span").click() 
driver.find_element_by_xpath("//font/label[2]/i").click() 
+0

試試這個'driver.find_element_by_xpath(「//李[@類選擇相同則它可是=」 NG-範圍'] [9]「)。單擊()'。 – JRodDynamite

+0

要完成@JasonEstibeiro的評論,請先嚐試: 'driver.find_element_by_xpath(「// span [@ class ='ng-binding']」)。click()' 要使選項可見,並單擊選項: 'driver.find_element_by_xpath( 「//李[@類= 'NG-範圍'] [9]」)點擊()' – Javitronxo

+0

或者,這似乎是一個更好的選擇。試試看吧'driver.find_element_by_xpath( 「//跨度[@類= 'NG結合' 和文本()= '理念'] [1]」)。點擊()'。讓我知道他們是否有任何工作。 – JRodDynamite

回答

2

我嘗試此代碼相同的網頁和工作:

driver.find_element_by_xpath("//span[contains(text(), 'Select Operator')]").click() 
driver.find_element_by_xpath("//span[contains(text(), 'Idea')]/..").click() 

重要的是,你首先要看到的選項潘內爾,否則會拋出以下異常:

selenium.common.exceptions.ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with 

更新時間:

要選擇孟買選項:

driver.find_element_by_xpath("//span[contains(text(), 'Select Circle')]").click() 
driver.find_element_by_xpath("//span[contains(text(), 'Mumbai')]/..").click() 
+0

謝謝....它wroked ...我已經更新了我的問題....ñ嘗試了很多的闖民宅你選擇的想法後,提供...「的代碼來實現同樣的,我得到一個新的下拉菜單中選擇用於需要選擇孟買「....你能幫助plz –

+0

@ user3388005更新.. – Javitronxo

1

首先點擊選擇框,然後選擇該選項,選擇您需要單擊第三個孩子沃達豐:

driver.find_element_by_css_selector(".select").click() 
driver.find_element_by_css_selector(".options > ul:nth-child(1) > li:nth-child(3)").click() 

其他選項如下如下:

.options > ul:nth-child(1) > li:nth-child(2) => Artiel 
.options > ul:nth-child(1) > li:nth-child(3) => Vodafone 
.options > ul:nth-child(1) > li:nth-child(4) => BSNL 

您選擇第一個選擇框後有2個選擇框,您可以通過find_elements_by_css_selector()與pulural

# select first one 
driver.find_element_by_css_selector(".select").click() 
driver.find_element_by_css_selector(".options > ul:nth-child(1) > li:nth-child(3)").click() 
# select second selectbox 
# you may need to sleep until second selectbox is available 
sleep(1) 
driver.find_elements_by_css_selector(".select")[1].click() 
driver.find_element_by_css_selector(".options.open > ul:nth-child(1) > li:nth-child(5)").click() # 5 option is Mumbai 
+0

謝謝....它的工作...我已經更新了我的問題.... n試了很多實施同樣通過引用你提供的代碼...「選擇想法後,我得到一個新的下拉選擇圈。需要選擇孟買「....你能幫助PLZ –

+0

@ user3388005看到更新的一個 –

-1

硒蟒蛇floorselectionWait = WebDriverWait(driver,20).until(EC.presence_of_element_located((By.XPATH,'//*[@id="select_22"]'))) floorselection=driver.find_element(By.XPATH,'//*[@id="select_22"]') floorselection.click() flooroptionsWait = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"//DIV[@class='md-text ng-binding'][text()='Level 7']"))) optionSelect=driver.find_element(By.XPATH,"//DIV[@class='md-text ng-binding'][text()='Level 7']") optionSelect.click() angularjs MD-選擇MD-選項選擇

相關問題