selenium

Selenium / lxml : Get xpath

六眼飞鱼酱① 提交于 2021-02-08 03:44:32
问题 Is there a get_xpath method or a way to accomplish something similar in selenium or lxml.html. I have a feeling that I have seen somewhere but can't find anything like that in the docs. Pseudocode to illustrate: browser.find_element_by_name('search[1]').get_xpath() >>> '//*[@id="langsAndSearch"]/div[1]/form/input[1]' 回答1: As there is no unique mapping between an element and an xpath expression, a general solution is not possible. But if you know something about your xml/html, it might be easy

webdriver modal window click() not working

孤街醉人 提交于 2021-02-08 03:41:38
问题 I've been browsing around trying to find a solution to this but none of the solutions have worked for me thus far. Here is a quick test I've thrown together where its simply trying to click the 'close' button to close a modal pop up. I can step through my test in Visual Studio and it will work fine. When I run the test in Nunit, it will error. I've tried the following based upon others issues and suggestions given to them:- putting in waits all over the place changing from the chrome driver

How to identify and switch to the frame in selenium webdriver when frame does not have id and title

你。 提交于 2021-02-08 03:41:37
问题 Can anyone tell me how I can identify and switch to the iframe which hasn't title and id. I need to get into this frame in order to find another element in this frame for sending some text. <div class="sceditor-container" style="width: 1359px; height: 300px;"> <div class="sceditor-toolbar"> <iframe frameborder="0" src="javascript:false" style="width: 1349px; height: 261px;"> <!DOCTYPE html> <html style="height:100%"> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type">

How to identify and switch to the frame in selenium webdriver when frame does not have id and title

﹥>﹥吖頭↗ 提交于 2021-02-08 03:41:08
问题 Can anyone tell me how I can identify and switch to the iframe which hasn't title and id. I need to get into this frame in order to find another element in this frame for sending some text. <div class="sceditor-container" style="width: 1359px; height: 300px;"> <div class="sceditor-toolbar"> <iframe frameborder="0" src="javascript:false" style="width: 1349px; height: 261px;"> <!DOCTYPE html> <html style="height:100%"> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type">

Cannot open a newtab in selenium webdriver on Mac OS X

て烟熏妆下的殇ゞ 提交于 2021-02-08 03:40:26
问题 I should be able to open a new tab in selenium for python using the code from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Firefox() driver.get("http://stackoverflow.com/") body = driver.find_element_by_tag_name("body") body.send_keys(Keys.COMMAND + 't') But no new tab opens, and no error message appears (http://stackoverflow.com/ does load). Note that I am using Keys.COMMAND + 't' because I am running the code on OS X. I have no idea what is

Locate element with selenium Xpath for date picker drop-down menu in Python?

﹥>﹥吖頭↗ 提交于 2021-02-08 03:35:09
问题 I wanted to click on the date in the dropdown datepicker. Bus the error occurs Unable to Locate Element . I tried : monyear = driver.find_element_by_xpath('/html/body/div[7]/div[1]/table/tbody/tr[5]/td[1]').click() and element=WebDriverWait(driver,30).until(ec.element_to_be_clickable((By.XPATH,"/html/body/div[7]/div[1]/table/tbody/tr[5]/td[1]"))) driver.execute_script("arguments[0].click();", element) But none of them worked for me. Please suggest the possible solutions for it . Here is the

Selenium - cant get text from span element

≯℡__Kan透↙ 提交于 2021-02-08 03:34:45
问题 I'm very confused by getting text using Selenium. There are span tags with some text inside them. When I search for them using driver.find_element_by_... , everything works fine. But the problem is that the text can't be got from it. The span tag is found because I can't use .get_attribute('outerHTML') command and I can see this: <span class="branding">ThrivingHealthy</span> But if I change .get_attribute('outerHTML') to .text it returns empty text which is not correct as you can see above.

Python Selenium CSS Selector by Span get_attribute

吃可爱长大的小学妹 提交于 2021-02-08 03:31:11
问题 I have already accessed a webpage, populated text boxes and drop downs with required parameters, and submitted (button click) this information so the webpage can perform a calculation. I am trying to access the results (value of text). Results should be a list of calculations listed least to greatest, and I only want the lowest value. I am not sure if I am having a timing issue or a CSS Selector issue. I have tried: e = driver.find_elements_by_css_selector("span[data-bind='calc']") new = e[0]

Python Selenium CSS Selector by Span get_attribute

纵饮孤独 提交于 2021-02-08 03:30:31
问题 I have already accessed a webpage, populated text boxes and drop downs with required parameters, and submitted (button click) this information so the webpage can perform a calculation. I am trying to access the results (value of text). Results should be a list of calculations listed least to greatest, and I only want the lowest value. I am not sure if I am having a timing issue or a CSS Selector issue. I have tried: e = driver.find_elements_by_css_selector("span[data-bind='calc']") new = e[0]

Finding elements by CSS selector with ChromeDriver (Selenium) in Python

允我心安 提交于 2021-02-08 03:06:54
问题 I'm using ChromeDriver of Selenium with Python and I'm trying to find a button on my page that has the following HTML: <input id="j_id0:SiteTemplate:j_id255:new" type="submit" name="j_id0:SiteTemplate:j_id255:new" value="New" class="kbutton-white"> The only thing I know being constant is the id and name ending with "new" and I'm trying to use the following code to identify and click that element: test_runner.driver.find_element_by_css_selector('[id*=new]').click() However, I get this error