I don't know why but i encounter this issue in only payment part. I execute script with other pages but i didn't get this warning.
def payments(self, cvc):
print("Paying for the shoe.")
self.chrome.execute_script("scroll(0, 300)") # for seeing buttons
# Need class and name at the same time because it is inside in iframe
self.wait_until_visible(xpath="//input[@class='pre-search-input headline-5' and @name='cardCvc']")
cvc_input = self.chrome.find_element_by_xpath("//input[@class='pre-search-input headline-5' and @name='cardCvc']")
cvc_input.clear()
cvc_input.send_keys(cvc)
self.wait_until_clickable(xpath="//button[@class='button button-continue']")
self.chrome.find_element_by_xpath("//button[@class='button button-continue']").click()
self.wait_until_clickable(xpath="//button[@class='button button-submit']")
self.chrome.find_element_by_xpath("//button[@class='button button-submit']").click()
print("Payment taken.")
This is my code that does not running. Before that error I encountered with another error like this: Refused to load the script 'http because it violates the following Content Security Policy directive with ChromeDriver Chrome headless Selenium.
I solved this error with this: self.chrome.execute_cdp_cmd("Page.setBypassCSP", {"enabled": True}) # to disable Contect Security Policy
Now i stuck at this error: The devicemotion events are blocked by feature policy. See https://github.com/WICG/feature-policy/blob/master/features.md#sensor-features polyfills.14f35e1be48465411559.js:1
I create my driver like this:
options = webdriver.ChromeOptions()
options.add_argument("--disable-web-security")
options.add_argument("--allow-running-insecure-content")
options.add_argument("--incognito")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument("user-data-dir=/Users/caner/Library/Application Support/Google/Chrome")
self.chrome = webdriver.Chrome(ChromeDriverManager().install(), options=options)
self.chrome.execute_cdp_cmd("Page.setBypassCSP", {"enabled": True})
Do you think i handle Content Security Policy in a right way. The difference between others pages and payment page is iframe. If you have any idea about this please let me know.
My Error is The devicemotion events are blocked by feature policy.
at some specific page(payment page). I just told there might be possibility. However it might not be related to iframe, or such thing Content Security Policy. I was just guessing. Is there any one have idea about this error?
I didnt see the same issue those links. Ways to deal with #document under iframe (2 answers) How can I select a html element no matter what frame it is in in selenium? (2 answers) Refused to load the script because it violates the following Content Security Policy directive: script-src error with ChromeDriver Chrome and Selenium Also the last link i applied their solution it seems that it solves the CSP problem. But i have new problem (The devicemotion events are blocked by feature policy.). Thats why it should not be duplicated question.