Posts

Showing posts with the label selenium

NoneType error during multi-page scrape

NoneType error during multi-page scrape I'm working on a web scraper and am close to getting what I need, but I can't figure out why I'm getting a NoneType error all of a sudden after it finishes scraping the fourth page (of 204). Here's my code: script_path = os.path.dirname(os.path.realpath(__file__)) driver = webdriver.PhantomJS(executable_path="/usr/local/bin/bin/phantomjs", service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any']) case_list = #this function launches the headless browser and gets us to the first page of results, which we'll scrape using main def search(): driver.get('https://www.courts.mo.gov/casenet/cases/nameSearch.do') if 'Service Unavailable' in driver.page_source: log('Casenet website seems to be down. Receiving "service unavailable"') driver.quit() gc.collect() return False time.sleep(2) court = Select(driver.find_element_by_i...

Chromedriver not clicking on object coordinates while in W10 VM

Chromedriver not clicking on object coordinates while in W10 VM I have a veeeeery weird issue I can not get solved, I am using Selenium together with Java, all bindings are up to date and Chrome browsers is up to date. My main testing is done in Windows machines using mobile emulation. When I launch my test cases in a Windows 7 real machine / Windows 7 Virtual Machine or Windows 10 real machine they are working ok, but when I launch them in any Windows 10 Virtual Machine selenium starts clicking on wrong coordinates. IE. I have a button placed in (70, 612), selenium is able to get the element coordinates without issues but when using click() it is actually clicking somewhere else (it is opening a banner or an event). If I use javascript click it is working with no issues, it is just selenium click() command and only in W10 VM (I have tried a Windows Server 2016 VM as well). I have tried to low and raise mobile pixel density and always having same results. As an extra, this issue is not...

Eclipse + Java + Selenium creates ClassNotFoundException

Eclipse + Java + Selenium creates ClassNotFoundException just getting started with Eclipse + Java + Selenium. Not doing anything fancy - My code looks like this: WebDriver driver = new ChromeDriver(); driver.get("http://www.google.com"); When I run, I get a ClassNotFoundException. I have selenium-java-2.48.2.jar in my Java Build Path. What am I missing? Can you add your stacktrace, so I could see the full exception messge. – Indrek Ots Dec 11 '15 at 16:20 Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available Launcher$AppClassLoader.loadClass(String, boolean) line: not available Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available TestApp.main(String) line: 9 – user306517 Dec 11 '15 at 16:24 ...

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 to find combined xpath for given text as ?

Image
how to find combined xpath for given text as < PMP & 8999 POINTS >? I want to find the combined xpath for the text <PMP & 8999 points> as follows: <PMP & 8999 points> PMP (Duration: 29 hrs | Difficulty: Intermediate | Language: english | Mode Of Training: online)  8999 Points </div> </div> 1 Answer 1 You can try with following x-path, //div[@class='lng-info']/*[name()='h5' or name()='div'] no,its pointing only to text= PMP – hack Jun 29 at 8:44 click on next button. – Murthi ...

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=...