selenium-webdriver

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

纵饮孤独 提交于 2021-02-08 03:01:32
问题 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

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

我的未来我决定 提交于 2021-02-08 03:00:51
问题 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

Unable to locate element for LABEL with the XPath expression

妖精的绣舞 提交于 2021-02-08 01:54:21
问题 I am trying the below xpath for Label, but I'm not able to locate the element. driver.findElement(By.xpath("//div[label[contains(text(),'Patient's Name']]")).isEnabled(); XPath: .//*[@id='update_patient_profile']/div/div[1]/label ---Taken from FirePath. Below is the HTML source for the field. <form id="update_patient_profile" action="/subscriber/" method="post" name="update_patient_profile"> <div class="subscriberAddPatient"> <div class="formData nameInputs"> <label for="first_name">Patient's

Headless Google Chrome: How to prevent sites to know whether their window is focused or not

橙三吉。 提交于 2021-02-07 20:31:39
问题 Is there a way to prevent sites to know if they are visible or not? Perhaps a command line flag? I checked here but I could not find anything suitable https://peter.sh/experiments/chromium-command-line-switches/. I think they use the page visibility API: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API 回答1: If your goal is to fool the visibility API, then inject this piece of script in the related page or frame: await page.evaluate(` Object.defineProperty(window.document,

How can i get display:none element using Selenium Webdriver c#?

吃可爱长大的小学妹 提交于 2021-02-07 17:33:16
问题 enter image description here Please provide me the scripting code in C# to get the text of the element that are marked in blue box. I am using Selenium Web driver and I want to get the value:10975 in the td tag. I tried the following code: IWebElement tableLocator = divLocator.FindElement(table); IWebElement tbodyFind = tableLocator.FindElement(tbodytag); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.ElementIsVisible(trTag)); List

Break on exception in Chrome using Selenium

六眼飞鱼酱① 提交于 2021-02-07 13:34:20
问题 In order to investigate some Selenium test failures I would like to automatically enable the pause on exception feature in the Chrome Devtools when running the tests. There is the --auto-open-devtools-for-tabs command line option for automatically opening the DevTools pane which I am already using but apparently there is no CLI option/parameter for the autopause feature I am looking for. What I came across though is the Debugger.setPauseOnExceptions Chrome Devtools Protocol command which I

Break on exception in Chrome using Selenium

穿精又带淫゛_ 提交于 2021-02-07 13:31:04
问题 In order to investigate some Selenium test failures I would like to automatically enable the pause on exception feature in the Chrome Devtools when running the tests. There is the --auto-open-devtools-for-tabs command line option for automatically opening the DevTools pane which I am already using but apparently there is no CLI option/parameter for the autopause feature I am looking for. What I came across though is the Debugger.setPauseOnExceptions Chrome Devtools Protocol command which I

First character is missing inconstantly while sending string to the ExtJS input via sendKeys()

∥☆過路亽.° 提交于 2021-02-07 13:21:42
问题 I randomly face the issue of missing first character in the ExtJS5 input field, while sending string via sendKeys method. System info: Ubuntu 14.04 -> docker containers with selenium grid (2.48.2) Browser Firefox Code is simple. I just get input web element, wait if it's clickable (i.e. isEnabled and isDisplayed), clear and send string: wait.until(ExpectedConditions.elementToBeClickable(input)).clear(); input.sendKeys(value); input element is simple too: <input id="textfield-1455-inputEl"

First character is missing inconstantly while sending string to the ExtJS input via sendKeys()

删除回忆录丶 提交于 2021-02-07 13:20:07
问题 I randomly face the issue of missing first character in the ExtJS5 input field, while sending string via sendKeys method. System info: Ubuntu 14.04 -> docker containers with selenium grid (2.48.2) Browser Firefox Code is simple. I just get input web element, wait if it's clickable (i.e. isEnabled and isDisplayed), clear and send string: wait.until(ExpectedConditions.elementToBeClickable(input)).clear(); input.sendKeys(value); input element is simple too: <input id="textfield-1455-inputEl"

How to make selenium webdriver open in google chrome without Incognito

不想你离开。 提交于 2021-02-07 11:15:00
问题 I'm using selenium for the past 1 month. I want to create some small applications using selenium. Selenium webdriver opens an incognito window when I run it. Is there any way to make it launch in normal window(i.e which has my accounts logged in)? This is the code which I'm using : (python code in linux) chromedriver = Path to chrome driver os.environ["webdriver.chrome.driver"] = chromedriver driver = webdriver.Chrome(chromedriver) driver.get("http://www.gmail.com") 回答1: If you want to re-use