Posts

Showing posts with the label selenium

How to retieve specific text from a tag without using contains() and xpath?

How to retieve specific text from a tag without using contains() and xpath? <div> <label1>Hulk</label1> <label2>Ironman</label2> Thor </div> How do I get only Thor text without using contains in xpath ? If I try getting text of div it would give me all the 3(Hulk,Ironman,Thor) but I want only Thor. Show how did you try, current and desired output, add tag for your programming language – Andersson Jul 2 at 10:21 Assuming that the typo <label1? is fixed, and that there are no other div s in the document, //div/text() will select Thor . – jsheeran Jul 2 at 10:29 <label1? div //div/text() Thor @jsheeran ,...

Selenium search by tag name option

Image
Selenium search by tag name option I'm trying to get all data from a website called Correios, in this website, I need to handle some dropdowns wich i'm having some issues like: It's returning a list with a bunch of empty strings. That's my code: chrome_path = r"C:\Users\Gustavo\Desktop\geckodriver\chromedriver.exe" driver = webdriver.Chrome(chrome_path) lista_x = driver.get("http://www2.correios.com.br/sistemas/agencias/") driver.maximize_window() dropdownEstados = driver.find_elements_by_xpath("""//*[@id="estadoAgencia"]""") optEstados = driver.find_elements_by_tag_name("option") for valores in optEstados: print(valores.text.encode()) And what i get from that is: b'' b'ACRE' b'ALAGOAS' b'AMAPxc3x81' b'AMAZONAS' b'BAHIA' b'CEARxc3x81' b'DISTRITO FEDERAL' b'ESPxc3x8dRITO SANTO' b'GOIxc3x81S' b'MARANHxc3x83O' b...

How to select element from a list and go to parent and then sibling (by Xpath)

How to select element from a list and go to parent and then sibling (by Xpath) I am trying to find a way to press button that is in the same tr as text with which I can localize specific file that I'd like to download. I'll describe it in details: there is a website that contains many tr. Each tr contains couple child td. These td contain description and download button. I need to localize desired tr by description of its td. Then I'd like to go to td that contains download button for this tr. Descriptions are different but I am interested only in those that contain 'DV' text. There is always couple of them on a website but I'd like to select first. What i've figured out so far is: $x("//*[contains(text(), 'DV')]")[0] And then I have no idea how to go to parent element and then to sibling td that contains download button. HTML looks something like that <tr> <td class='a'>DV some other characters1</td><td class=...

Error: Failed to create scenario runner while using examples

Error: Failed to create scenario runner while using examples I am using Examples to enter the email but when I run the junit runner file it gives me the error: " Failed to create scenario runner" My Junit runner code: package Runner; import org.junit.runner.RunWith; import cucumber.api.junit.Cucumber; import cucumber.api.junit.Cucumber.Options; @RunWith(Cucumber.class) @Options(features="Features",glue={"stepdefinition"}) public class GmailRunner { } Here is my feature file: Feature: Smoke test of Gmail @GmailSignin Scenario Outline: Click on Sign in Given Open chrome When I go to gmail and click on Sign in When I enter "<emailid>" Then I click on next Examples: | emailid | | sarveshsingh.03 | I am using Cucumber-junit-1.1.2 and junit-4.11 Please help could you try upgrading your cucumber-junit ? – Prany Jul 2 at 3:52 ...

How can I get a intermediate URL from a redirect chain from Selenium using Python?

How can I get a intermediate URL from a redirect chain from Selenium using Python? I'm using Selenium with Python API and Firefox to do some automatic stuff, and here's my problem: So is there a way to get the intermediate redirect URL b.com/some/path?arg=value with Selenium Python API? I tried driver.current_url but when the browser is on b.com , seems the browser is still under loading and the result returned only if the final address c.com is loaded. driver.current_url Another question is that is there a way to add some event handlers to Selenium for like URL-change? Phantomjs has the capacity but I'm not sure for Selenium. 4 Answers 4 You can get redirects from performance logs. According to docs and github answer here is what I've done in C#, should be possible to port in Python: performance var options = new ChromeOptions(); var cap = DesiredCapabilities.Chrome(); var perfL...