Posts

Showing posts with the label selenium-webdriver

What is the JavaScript equivalent of python's .text?

Image
What is the JavaScript equivalent of python's .text? Element.text returns the text content of an element. In a different thread on SO, the python script scrapes data from the followers modal on an Instagram account. The following part returns the text inside the lists and stores them in an array. xpath = "//div[@style='position: relative; z-index: 1;']//ul/li/div/div/div/div/a" followers_elems = driver.find_elements_by_xpath(xpath) return [e.text for e in followers_elems] I'm trying to achieve a similar result in JavaScript (I'm using WebDriverJS) : const XPATH = "/html/body/div[3]/div/div[2]/div/div[2]/ul/div/li"; var followers_elems = await driver.findElements(By.xpath(XPATH)); var followers_temp = ; for (var e in followers_elems) { followers_temp.push(e.textContent); } console.log(followers_temp); I'm not sure if textContent is the right property for .text . I've tried a million different alternatives but all I'm getting...

How to change language in web page using Selenium(Java)?

How to change language in web page using Selenium(Java)? Is their a way to pre-define a language for webpage? I want to load google page in Spanish, can we set property of webdriver in such a way that it load the page in Spanish. What the URL you are using? I think you can just use this URL: google.es – igreenfield Apr 22 '15 at 5:32 Can i set the browser property to load pages in particular language.. – Nick Apr 22 '15 at 6:05 1 Answer 1 Check this link: For Firefox: FirefoxProfile profile = new FirefoxProfile(); profile.setPreference( "intl.accept_languages", ...

Safari-Headless in Selenium for Windows

Safari-Headless in Selenium for Windows Can i get a piece of code to automate Safari browser in headless mode for Selenium automation in Windows OS? I tied with many configuration but fails. Can anyone suggest the simple code that can easily change to another browsers to run headless mode? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

What is the difference between defaultcontent() and Parentframe() method in selenium webDriver?

Image
What is the difference between defaultcontent() and Parentframe() method in selenium webDriver? What is difference between below two methods : driver.switchTo().parentFrame(); driver.switchTo().defaultContent(); 3 Answers 3 As per the specifications, driver.switchTo().parentFrame(); invokes the following: driver.switchTo().parentFrame(); Where, the Switch to Parent Frame command sets the current browsing context for future commands to the parent of the current browsing context . As per the Java Docs parentFrame() method changes the focus to the parent context. If the current context is the top level browsing context, the context remains unchanged. As per the Java Docs , defaultContent() method selects either the first frame on the page, or the main document when a page contains iframes. That mean for example If i have 3 frames which are nested frames i1, i2, i3. I...

How can I find the randomly Xpath using Selenium?

How can I find the randomly Xpath using Selenium? I am a newer in Selenium and use python to build it. Recently, I found a question which want to ask someone who can help me to figure it. The question is the Xpath I want to get is randomly, for example: '//*[@id="wiki-edit-wikiEdit26"]/div/div/div/div[2]/a[1]' '//*[@id="wiki-edit-wikiEdit27"]/div/div/div/div[2]/a[1]' '//*[@id="wiki-edit-wikiEdit28"]/div/div/div/div[2]/a[1]' These three xpath are used on the same button, but the number after wikiEdit will be changed every time. Therefore, are there any way which can help me to run my script more smoothly? Thank you very much! xpath Here is my python code: broswer.find.element_by_xpath('//*[@id="wiki-edit-wikiEdit26"]/div/div/div/div[2]/a[1]') .click() do you want to change no. in wikiEdit ? – Raghav Patnecha 33 mins ago ...

I want to click on buttons(of same name but having different href) using selenium.is it possible?

I want to click on buttons(of same name but having different href) using selenium.is it possible? Basically i want to click on MoreInfo button from this website: Website is: https://www.usta.com/en/home/play/facility-listing.html?searchTerm=&distance=5000000000&address=Palo%20Alto,%20%20CA The thing what i want is it either its possible to click MoreInfo button one by one or not? if so then please suggest my idea for it. Thanks import time import requests from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ActionChains import re # ----------------------------------------------HANDLING-SELENIUM-STUFF------------------------------------------------- driver = webdriver.Chrome() time.sleep(5) driver.get('https://www.usta.com/en/home/play/facility-listing.html?searchTerm=&distance=...