PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label css-selectors. Show all posts
Showing posts with label css-selectors. Show all posts

Thursday, December 1, 2022

[FIXED] How to access the iframe using Selenium and Python on Glassdoor

 December 01, 2022     css-selectors, iframe, python, selenium, xpath     No comments   

Issue

I am trying to automate application process on Glassdoor using the EasyApply button. Now after identifying the EasyApply Button and successfully clicking it, I need to switch to the Frame so as to access the HTML content of the form to be able to send in my form details.

I used:

wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "#indeedapply-modal-preload-1658752913396-iframe")))

to perform the switching but still could not access the frame's html content.

Here is the block that performs this operation:

from selenium.webdriver.support.ui import WebDriverWait, Select
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
#if it has easy-apply, then perform application

if len(driver.find_elements_by_xpath('//*[@id="JDCol"]/div/article/div/div[1]/div/div/div[1]/div[3]/div[2]/div/div[1]/div[1]/button')) > 0:
    driver.find_element_by_xpath('//*[@id="JDCol"]/div/article/div/div[1]/div/div/div[1]/div[3]/div[2]/div/div[1]/div[1]/button').click()
    wait = WebDriverWait(driver, 50)
    time.sleep(5)
    wait.until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR, "#indeedapply-modal-preload-1658752913396-iframe")))
    name = driver.find_element(By.CSS_SELECTOR, '#input-applicant.name')
    name.send_keys('Oluyele Anthony')
elif len(driver.find_elements_by_xpath('//*[@id="JDCol"]/div/article/div/div[1]/div/div/div[1]/div[3]/div[2]/div/div[1]/div[1]/a')) > 0:
    driver.find_element_by_xpath('//*[@id="JDCol"]/div/article/div/div[1]/div/div/div[1]/div[3]/div[2]/div/div[1]/div[1]/a').click()

Here is the HTML content for the frame

<iframe name="indeedapply-modal-preload-1659146630884-iframe" id="indeedapply-modal-preload-1659146630884-iframe" scrolling="no" frameborder="0" title="Job application form container" src="https://apply.indeed.com/indeedapply/xpc?v=5#%7B%22cn%22:%224AaHlXdnW4%22,%22ppu%22:%22https://www.glassdoor.com/robots.txt%22,%22lpu%22:%22https://apply.indeed.com/robots.txt%22,%22setupms%22:1659146630959,%22preload%22:true,%22iaUid%22:%221g96dgr7uii3h800%22,%22parentURL%22:%22https://www.glassdoor.com/Job/nigeria-data-science-jobs-SRCH_IL.0,7_IN177_KO8,20.htm?clickSource=searchBox%22%7D" style="border: 0px; vertical-align: bottom; width: 100%; height: 100%;"></iframe>

Apparently, after running the cell, the:

TimeoutException: Message:

Error occurs which shows that the frame is not being switched to.


Solution

The middle part of the value of id attribute i.e. 1658752913396 is dynamically generated and is bound to change sooner/later. They may change next time you access the application afresh or even while next application startup. So can't be used in locators.


Solution

To switch to the <iframe> you can use either of the following Locator Strategies:

  • Using id attribute:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='Job application form container'][id^='indeedapply-modal-preload']")))
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[title='Job application form container' and starts-with(@id, 'indeedapply-modal-preload')]")))
      
  • Using name attribute:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='Job application form container'][name^='indeedapply-modal-preload']")))
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[title='Job application form container' and starts-with(@name, 'indeedapply-modal-preload')]")))
      
  • Note : You have to add the following imports :

     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support import expected_conditions as EC
    


Answered By - undetected Selenium
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, October 16, 2022

[FIXED] How do you enable :has() selector on Firefox

 October 16, 2022     css, css-selectors, firefox, settings     No comments   

Issue

When I check the :has() css selector on caniuse.com, it tells me that since Firefox103 it has been "Supported in Firefox behind the layout.css.has-selector.enabled flag". So how do I find this flag and enable it?


Solution

Go to the Firefox about:config page, then search and toggle layout.css.has-selector.enabled.

enter image description here



Answered By - Cédric
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, September 18, 2022

[FIXED] How to only show certain parts with CSS for Print?

 September 18, 2022     css, css-selectors, printing     No comments   

Issue

I have a page with lots of data, tables and content. I want to make a print version that will only display very few selected things.

Instead of writing another page just for printing, I was reading about CSS's feature for "@media print".

First, what browsers support it? Since this is an internal feature, it's OK if only the latest browsers support it.

I was thinking of tagging a few DOM elements with a "printable" class, and basically apply "display:none" to everything except those elements with the "printable" class. Is that doable?

How do I achieve this?

EDIT: This is what I have so far:

<style type="text/css">
@media print {
    * {display:none;}
    .printable, .printable > * {display:block;}
}
</style>

But it hides everything. How do I make those "printable" elements visible?

EDIT: Trying now the negative approach

<style type="text/css">
@media print {
    body *:not(.printable *) {display:none;}
}
</style>

This looks good in theory, however it doesn't work. Maybe "not" doesn't support advanced css ...


Solution

Start here. But basically what you are thinking is the correct approach.

Thanks, Now my question is actually becoming: How do I apply CSS to a class AND ALL OF ITS DESCENDANT ELEMENTS? So that I can apply "display:block" to whatever is in the "printable" zones.

If an element is set to display:none; all its children will be hidden as well. But in any case. If you want a style to apply to all children of something else, you do the following:

.printable * {
   display: block;
}

That would apply the style to all children of the "printable" zone.



Answered By - Strelok
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, June 27, 2022

[FIXED] How to use the :not selector in Cytoscape.js? (To select nodes that don't have an attribute)

 June 27, 2022     css-selectors, cytoscape.js, graph, javascript     No comments   

Issue

I'm trying to use the :not selector in cytoscape.js. I want to select all nodes that don't have a specific attribute to open an context menu. E.g.:

cy.cxtmenu({
    selector: not('node.selection'),
    commands: [ .... ]
});

But I'm not sure how I can do this in cytoscape.js. Any help will be welcome.


Solution

[^name] Matches elements if the specified data attribute is not defined, i.e. undefined (e.g [^foo]). Here, null is considered a defined value.

http://js.cytoscape.org/#selectors/data



Answered By - maxkfranz
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, April 15, 2022

[FIXED] How do I handle cookie accept button within nested iframes in selenium with python?

 April 15, 2022     css-selectors, iframe, python, selenium, xpath     No comments   

Issue

I've tried almost everything and searched on SO but can't get passed the cookie accept on gmx.com. Hoping someone can help out. So far I've tried:

driver = webdriver.Chrome(CHROMEPATH)
driver.get('https://www.gmx.com')
time.sleep(5)
cookie_accept = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, '//button[@id="onetrust-accept-btn-handler"]')))
cookie_accept.click()

===AND===

driver = webdriver.Chrome(CHROMEPATH)
driver.get('https://www.gmx.com')
wait = WebDriverWait(driver, 15)
wait.until(EC.element_to_be_clickable(
    (By.CSS_SELECTOR, "div[style='onetrust-style'] button[id*='onetrust-accept-btn-handler']")))
driver.find_element_by_css_selector("div[style='onetrust-style'] button[id*='onetrust-accept-btn-handler']").click()
time.sleep(10)
driver.quit()

What am I doing wrong?! Any help is greatly appreciated!!


Solution

The element Agree and continue is within nested elements so you have to:

  • Induce WebDriverWait for the parent frame to be available and switch to it.

  • Induce WebDriverWait for the child frame to be available and switch to it.

  • Induce WebDriverWait for the desired element to be clickable.

  • You can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      driver.get("https://www.gmx.com/consentpage")
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe.permission-core-iframe")))
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[src^='https://plus.gmx.com/lt']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#onetrust-accept-btn-handler"))).click()
      
    • Using XPATH:

      driver.get("https://www.gmx.com/consentpage")
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@class='permission-core-iframe']")))
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[starts-with(@src, 'https://plus.gmx.com/lt')]")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@id='onetrust-accept-btn-handler']"))).click()
      
  • Note : You have to add the following imports :

     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

GMX


Reference

You can find a couple of relevant discussions in:

  • Ways to deal with #document under iframe
  • Switch to an iframe through Selenium and python
  • selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element while trying to click Next button with selenium
  • selenium in python : NoSuchElementException: Message: no such element: Unable to locate element


Answered By - undetected Selenium
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to extract the src attribute of an iframe using Selenium and C#

 April 15, 2022     c#, css-selectors, iframe, selenium, xpath     No comments   

Issue

I use selenium webdriver with C#,

<iframe class="x-component x-fit-item x-component-default" id="component-1105" name="ets_grd_02_IFrame" src="frm_01_master_training_plan.aspx?RID=196&amp;RIU=U&amp;_dc=1641984641351" frameborder="0" style="margin: 0px; width: 718px; height: 535px;"></iframe>

I need to get src attribute of this element. I can locate inside of this iframe and make operations on the form which is located inside that iframe but I can't get src attribute.


Solution

To get the iframe src attribute:

driver.SwitchTo().DefaultContent(); // call this or make sure you are not already switched to this iframe
string iframeSrc = driver.FindElement(By.Xpath("//iframe[contains(@id, 'component-')]")).getAttribute("src")

To interact with the iframe elements:

IWebElement frame = driver.FindElement(By.Xpath("//iframe[contains(@id, 'component-')]"))
driver.SwitchTo().Frame(frame);
// do somethind you like within iframe
driver.SwitchTo().DefaultContent();

Make sure that your target iframe is not placed within some parent iframe. Otherwise, you'll have to first switch to the parent iframe to access the current one.



Answered By - Max Daroshchanka
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to send text within an input field with contenteditable="true" within an iframe using Selenium and Python

 April 15, 2022     css-selectors, iframe, python, selenium, xpath     No comments   

Issue

I am writing a webscraping script that automatically logs into my Email account and sends a message.

I have written the code to the point where the browser has to input the message. I don't know how to access the input field correctly. I have seen that it is an iframe element. Do I have to use the switch_to_frame() method and how can I do that? How can I switch to the iframe if there is no name attribute? Do I need the switch_to_frame() method or can I just use the find_element_by_css_selector() method?

This is the source code of the iframe:

enter image description here

Here is my code:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

myPassword = 'xxxxxxxxxxxxxxxx'

browser = webdriver.Firefox() # Opens Firefox webbrowser
browser.get('https://protonmail.com/') # Go to protonmail website
loginButton = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "a.btn-ghost:nth-child(1)")))
loginButton.click()
usernameElem = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#username")))
usernameElem.send_keys("first.last@protonmail.com")
passwordElem = browser.find_element_by_css_selector("#password")
passwordElem.send_keys(myPassword)
anmeldenButton = browser.find_element_by_css_selector(".button")
anmeldenButton.click()
newMessage = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.XPATH, "/html/body/div[1]/div[3]/div/div/div[1]/div[2]/button")))
newMessage.click()
addressElem = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[id^='to-composer']")))
addressElem.send_keys('first.last@mail.com')
subjectElem = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[id^='subject-composer']")))
subjectElem.send_keys('anySubject')
messageElem = WebDriverWait(browser, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#squire > div > div:nth-child(1)")))
messageElem.send_keys('message')

Solution

To access the <input> field within the iframe so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • Induce WebDriverWait for the desired element to be clickable.

  • You can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='Editor']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#squire"))).send_keys('message')
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='Editor']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='squire']"))).send_keys('message')
      
  • Note : You have to add the following imports :

     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support import expected_conditions as EC
    

PS: As the <div> tag is having the attribute contenteditable="true" you can still send text to the element.


Reference

You can find a couple of relevant discussions in:

  • Switch to an iframe through Selenium and python
  • selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element while trying to click Next button with selenium
  • selenium in python : NoSuchElementException: Message: no such element: Unable to locate element


Answered By - undetected Selenium
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to locate and click on the recaptcha checkbox using Selenium and Python

 April 15, 2022     css-selectors, iframe, python, selenium, xpath     No comments   

Issue

I've already tried in several ways to click this checkbox with selenium and I couldn't. Link: http://buscatextual.cnpq.br/buscatextual/email.do?metodo=apresentar&seqIdPessoa=246740&nomeDestinatario=Maria_Jos%E9_Panichi_Vieira I already tried with XPATH, with CLASS_NAME and others, but the return is always the same:

no such element: Unable to locate element:

Can anyone help me?

Code trials:

from selenium import webdriver
from time import sleep

from selenium.webdriver.common.by import By

from selenium.webdriver.chrome.options import Options
from fake_useragent import UserAgent
from capmonster_python import RecaptchaV2Task

class ChromeAuto:
    def __init__(self):
        options = Options()
        ua = UserAgent()
        self.userAgent = ua.random
        print(self.userAgent)
        options.add_argument(f'user-agent={self.userAgent}')
        self.driver_path = r'chromedriver'
        self.options = webdriver.ChromeOptions()
        self.options.add_argument('--profile-directory=1')
        self.options.add_experimental_option("excludeSwitches", ["enable-automation"])
        self.options.add_experimental_option("useAutomationExtension", False)
        self.captcha = RecaptchaV2Task("c6eea325a7a78273c062d2bb23a2a43d")

        self.chrome = webdriver.Chrome(
            self.driver_path,
            options=self.options
        )
    def test(self):
        self.chrome.get('http://buscatextual.cnpq.br/buscatextual/email.do?metodo=apresentar&seqIdPessoa=246740&nomeDestinatario=Maria_Jos%E9_Panichi_Vieira')
        sleep(5)
        self.chrome.find_element(By.XPATH, '//*[@id="recaptcha-anchor"]/div[1]').click()

if __name__ == '__main__':
    chrome = ChromeAuto()
    chrome.test()

Solution

The ReCaptcha checkbox is within an <iframe> so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.
  • Induce WebDriverWait for the desired element to be clickable.
  • You can use either of the following Locator Strategies:
    • Using CSS_SELECTOR:

      driver.get('http://buscatextual.cnpq.br/buscatextual/email.do?metodo=apresentar&seqIdPessoa=246740&nomeDestinatario=Maria_Jos%E9_Panichi_Vieira')
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='reCAPTCHA']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.recaptcha-checkbox-border"))).click()
      
    • Using XPATH:

      driver.get('http://buscatextual.cnpq.br/buscatextual/email.do?metodo=apresentar&seqIdPessoa=246740&nomeDestinatario=Maria_Jos%E9_Panichi_Vieira')
      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='reCAPTCHA']")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.recaptcha-checkbox-border"))).click()
      

PS: Clicking on the ReCaptcha checkbox opens the image selection panel.

  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser Snapshot:

click_captcha


Reference

You can find a couple of relevant discussions in:

  • Switch to an iframe through Selenium and python
  • selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element while trying to click Next button with selenium
  • selenium in python : NoSuchElementException: Message: no such element: Unable to locate element


Answered By - undetected Selenium
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to identify the iframe using Selenium?

 April 15, 2022     css-selectors, iframe, python, selenium, xpath     No comments   

Issue

HTML:

<iframe allowpaymentrequest="true" allowtransparency="true" src="https://shopify.wintopay.com/
cd_frame_id_="ca9e4ad6a1559de159faff5c1f563d59"
name="WinCCPay"
id="win-cc-pay-frame" 

I'm trying to input text in a CC field. Apparently its in an iframe I picked the last one in the HTML and tried to select it from the identifiers above but I keep getting the element couldn't be found

iframe= wd.find_element_by_id("win-cc-pay-frame")    

wd.switch_to.frame(iframe)

The frame is currently being shown in the browser so no need for implicit wait.


Solution

To identify the <iframe> so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • You can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe#win-cc-pay-frame[name='WinCCPay'][src^='https://shopify.wintopay.com']")))
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@id='win-cc-pay-frame' and @name='WinCCPay'][starts-with(@src, 'https://shopify.wintopay.com')]")))
      
  • Note : You have to add the following imports :

     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support import expected_conditions as EC
    


Answered By - undetected Selenium
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, April 14, 2022

[FIXED] How to locate an element inside this iframe with selenium?

 April 14, 2022     css-selectors, iframe, python, selenium, xpath     No comments   

Issue

I am tring to access an element inside this iframe:

I am tring to access an element inside this iframe

I tried to use switch_to.frame(0) first, but still can not locate the element inside the frame.

Screenshot of the error:

enter image description here


Solution

As the element is within an <iframe> so you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • You can use either of the following Locator Strategies:

    • Using CSS_SELECTOR:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[title='To Do Assignments in Connect'][src='https://connect.mheducation.com/paamweb/index.html#/access/home']")))
      
    • Using XPATH:

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@title='To Do Assignments in Connect' and @src='https://connect.mheducation.com/paamweb/index.html#/access/home']")))
      
  • Note : You have to add the following imports :

     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support import expected_conditions as EC
    

References

You can find a couple of relevant detailed discussions in:

  • How can I select a html element no matter what frame it is in in selenium?


Answered By - undetected Selenium
Answer Checked By - Marilyn (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, February 10, 2022

[FIXED] Symfony \ Component \ CssSelector \ Exception \ SyntaxErrorException cssselector to xpath in laravel

 February 10, 2022     css-selectors, domcrawler, laravel-5, symfony-css-selector, xpath     No comments   

Issue

I have following html select element, select element's attribute name containing square bracket and need to filter using domcrawler but unfortunately, CssSelectorConvertor() cannot convert cssselector to xpath because of square bracket in the name attribute.

HTML code of another page:

<select name="get_result[our_school_dis]">
    <option value="a">Result 1</value>
</select>

code in laravel controller:

$crawler = $client->request('GET', 'http://anotherpage.com/abc');
$converter = new CssSelectorConverter();
$converter->toXPath('select[name=result[our_school_dis]]');

It throws error as :

Symfony \ Component \ CssSelector \ Exception \ SyntaxErrorException
Expected "]", but <delimiter "[" at 22> found.

looking for appropriate solution

thank you


Solution

For attribute value that contains special character, use quotes in your CSS selector :

$converter->toXPath('select[name="result[our_school_dis]"]');


Answered By - har07
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing