xpath

How to find an element with respect to the user input using Selenium and Python?

做~自己de王妃 提交于 2020-06-23 12:54:49
问题 The following is the HTML structure: <div class='list'> <div> <p class='code'>12345</p> <p class='name'>abc</p> </div> <div> <p class='code'>23456</p> <p class='name'>bcd</p> </div> </div> And there is a config.py for user input. If the user input 23456 to config.code, how can the selenium python select the second object? I am using find_by_css_selector() to locate and select the object, but it can only select the first object, which is Code='12345' . I tried to use find_by_link_text() , but

How to find an element with respect to the user input using Selenium and Python?

送分小仙女□ 提交于 2020-06-23 12:51:06
问题 The following is the HTML structure: <div class='list'> <div> <p class='code'>12345</p> <p class='name'>abc</p> </div> <div> <p class='code'>23456</p> <p class='name'>bcd</p> </div> </div> And there is a config.py for user input. If the user input 23456 to config.code, how can the selenium python select the second object? I am using find_by_css_selector() to locate and select the object, but it can only select the first object, which is Code='12345' . I tried to use find_by_link_text() , but

How to retrieve partial text from a text node using Selenium and Python

别来无恙 提交于 2020-06-23 12:21:11
问题 I want to get only " text ... " not using .split() or index slicing HTML: <a class="call_recipe" href="/recipes/2913"> " text ... " <strong> something~ </strong> </a> HTML Snapshot: 回答1: To print text ... you have to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following Locator Strategies: Using CSS_SELECTOR and childNodes : print(driver.execute_script('return arguments[0].firstChild.textContent;', WebDriverWait(driver, 20).until(EC.visibility_of

How to retrieve partial text from a text node using Selenium and Python

霸气de小男生 提交于 2020-06-23 12:19:59
问题 I want to get only " text ... " not using .split() or index slicing HTML: <a class="call_recipe" href="/recipes/2913"> " text ... " <strong> something~ </strong> </a> HTML Snapshot: 回答1: To print text ... you have to induce WebDriverWait for the visibility_of_element_located() and you can use either of the following Locator Strategies: Using CSS_SELECTOR and childNodes : print(driver.execute_script('return arguments[0].firstChild.textContent;', WebDriverWait(driver, 20).until(EC.visibility_of

XSLT3 joining values with separator

大憨熊 提交于 2020-06-17 13:23:07
问题 I'm pretty new to XSLT and I've been struggling to replicate the solution mentioned here XSL for-each: how to detect last node? for longer than I'm willing to admit :( I've setup this fiddle. https://xsltfiddle.liberty-development.net/naZXVFi I was hoping I could use just the value-of + separator, vs choose / when xslt tools, as it did seem more idiomatic. I can't get the separator to show up; nor can I select just the child of skill, I always get the descendants too. That's to say, I shouldn

How to find elements without using the tag attribute?

倾然丶 夕夏残阳落幕 提交于 2020-06-16 17:25:42
问题 image = driver.find_elements_by_xpath("//img[contains(@class,'ui_qtext')]") copy = driver.find_elements_by_xpath("//p[contains(@class,'ui_qtext')]") I have this two elements with different tag_names. How do i locate them without the tag_name? Or how do i "combine" this two? Both have the same class_name. 回答1: To remove the dependency on the tagNames you can use either of the following Locator Strategies: Using xpath : image_copy = driver.find_elements_by_xpath("//*[contains(@class,'ui_qtext')

evaluateXPath runs slow for repeating 1 XML Element in java

喜夏-厌秋 提交于 2020-06-13 09:16:51
问题 I have about 1,000,000 XML files and I am using XpathExpression with Java language to walk through the XML tags and get my considered data. Imagine I have about 5000 tags for name, 5000 tags for family name, 5000 tags for age, and only 1 tag for date in each file. Now I want to repeat date tag to 5000 times too. Blow code is runnable for XML files with Java programming with less than 20MB size, but I have files with more than 20MB size and it takes so many times to run and in some cases, I

Read an unknown XML with namespaces, attributes etc. into a full EAV list

陌路散爱 提交于 2020-06-09 05:37:30
问题 After answering a question about how to read an unknown JSON I tried to find something similar for XML (triggered by this related question). The question is: How can I read the whole and everything out of an unknown XML? The ideal output is an EAV-list in the expected sort order together with a full XPath for the element: Full XPath (aware of any namespace and element position) Element's or attribute's name (with namespace) Content ( text() node or attribute's value) As the sort order is an

Protractor Conditional Selector

亡梦爱人 提交于 2020-06-08 12:37:53
问题 I am using Selenium Protractor and want to select all elements from the following list except one that contains text "Cat" and then perform some operations on the remaining ones. <div class="mainDiv"> <div class="childDiv">Dog</div> <div class="childDiv">Goat</div> <div class="childDiv">Bird</div> <div class="childDiv">Cat</div> <div class="childDiv">Zebra</div> </div> Is there a selector by cssContainingText (or some other) in which I can give a condition to select all elements except the

How to click on a element through Selenium Python

孤街浪徒 提交于 2020-06-06 08:18:08
问题 I'm trying to fetch data for facebook account using selenium browser python but can't able to find the which element I can look out for clicking on an export button. See attached screenshot I tried but it seems giving me an error for the class. def login_facebook(self, username, password): chrome_options = webdriver.ChromeOptions() preference = {"download.default_directory": self.section_value[24]} chrome_options.add_experimental_option("prefs", preference) self.driver = webdriver.Chrome(self