selenium-webdriver

Auto click a button in a web page

我们两清 提交于 2020-06-09 05:22:08
问题 I need to auto click on any of the "Add" buttons in a web page like as the following address: "https://groceries.asda.com/search/yoghurt" But, none of the "Add" buttons in the page has name or id. So I can not use driver.find_element_by_id() command from Selenium package. Can any one help me? 回答1: To click on any particular Add button for a particular product you can write a method as follows: def click_me(string): driver.find_element_by_xpath("//h3/a[@class='co-product__anchor' and contains(

How to get Inspect Element code in Selenium WebDriver

有些话、适合烂在心里 提交于 2020-06-07 21:29:11
问题 I'm working in selenium with Firefox browser. The Html code shown in View Source (CTRL+U) is different from the html code i see when inspecting the elements in Firefox. when i run the driver.getPageSource() i only get the View source (CTRL + U) codes. Is there is any way to access the Inspect element code instead of View source code ? 回答1: I think your question is answered here. The View Source html is what is sent by the server. I think of it as compile time html, or the initial state of the

selenium element not interactable

你离开我真会死。 提交于 2020-06-01 08:05:38
问题 i started using selenuim, node js it was working all perfect so far, sudenly the same script is throwing and error "unhandled promise rejection warning element not interactable" i tried setting wait, until and nothing <script> const {Builder, By, Key, until, wait } = require('selenium-webdriver'); var driver = new Builder() .forBrowser('chrome') .build(); driver.manage().window().maximize() driver.get('http://www.google.com/testsite') driver.findElement(By.id('username')).sendKeys('test@emal'

How to zoom out of page using python selenium

孤街醉人 提交于 2020-06-01 02:41:25
问题 I found this for java :- WebElement html = driver.findElement(By.tagName("html")); html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD)); But how to do this using Python? I want to zoom out one level after get requests. 回答1: You can do something similar where you specify the zoom levels as below: For example, if my body has a <div id='values'> , I could zoom the div using from selenium import webdriver def main(): browser = webdriver.Chrome() browser.set_window_size(1000, 1000) browser.get("http:

How to zoom out of page using python selenium

若如初见. 提交于 2020-06-01 02:40:31
问题 I found this for java :- WebElement html = driver.findElement(By.tagName("html")); html.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD)); But how to do this using Python? I want to zoom out one level after get requests. 回答1: You can do something similar where you specify the zoom levels as below: For example, if my body has a <div id='values'> , I could zoom the div using from selenium import webdriver def main(): browser = webdriver.Chrome() browser.set_window_size(1000, 1000) browser.get("http:

Chromeoptions and setExperimentalOption code

爱⌒轻易说出口 提交于 2020-06-01 01:00:22
问题 I am unable to understand the meaning of following lines of code for setting up Chromeoptions in selenium code Can someone explain its meaning and als provide some external link for further learning -: ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); prefs.put("profile.default_content_setting_values.notifications", 2); options

Chromeoptions and setExperimentalOption code

余生长醉 提交于 2020-06-01 00:59:22
问题 I am unable to understand the meaning of following lines of code for setting up Chromeoptions in selenium code Can someone explain its meaning and als provide some external link for further learning -: ChromeOptions options = new ChromeOptions(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("credentials_enable_service", false); prefs.put("profile.password_manager_enabled", false); prefs.put("profile.default_content_setting_values.notifications", 2); options

How to write a text list to a defined csv file? Python selenium scraping

三世轮回 提交于 2020-05-30 08:13:07
问题 I am new to Python, so please forgive me if this is a simple issue. I am web scraping an entire experience section from Linkedin using Selenium. Below is my relevant code: from time import sleep from selenium import webdriver ChromeOptions = webdriver.ChromeOptions() driver = webdriver.Chrome('/Users/jones/Downloads/chromedriver') driver.get('https://www.linkedin.com/in/pauljgarner/') ##writing 'Name' to excel writer = csv.writer(open(parameters.file_name, 'w', encoding='utf8')) writer

javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite

大憨熊 提交于 2020-05-30 08:07:30
问题 I recently updated my chrome version to latest i.e. 79.0.3945.130 (Official Build) (64-bit) and downloaded compatible chromedriver from here I've started facing this error. While debugging in detail i found that the Select class causing the issue. wherever I'm selecting a dropdown in my code I'm getting this issue. The HTML of dropdown looks like below snippet: <div class="rd-input--wrapper" id="178"> <label for="attribute178">Flavour</label> <select name="super_attribute[178]" data-selector=

I need to capture Unit test case result and pass it into an array. How can I do that?

北战南征 提交于 2020-05-30 07:03:26
问题 I need to capture Unit test case result that is pass/fail in form of 1 and 2 and save it into an array for multiple test cases results. 1 for pass and 2 for fail. What if i need to save only one test case result? How can I do that? I am using Nunit C#. Using selenium webdriver. Here is the glimpse of my code [Priority(1)] [TestMethod] public void search() { Testlog.Info("Test ID:001); Testlog.Info("Select customer from cutomer dropdown"); var dc = gmethods.GetSelectElement(WDriver, dpo